mirror of
https://github.com/gravitl/netmaker.git
synced 2025-09-27 05:08:11 +08:00
Revert: changing mechanics of loop (for ease of pr review)
cherry-pick the ineffective `err` assignment to make our following error check not useless
This commit is contained in:
@@ -162,29 +162,18 @@ func GetPublicIP(api string) (string, error) {
|
||||
iplist = append([]string{api}, iplist...)
|
||||
}
|
||||
|
||||
var bodies []*http.Response
|
||||
defer func() {
|
||||
for _, res := range bodies {
|
||||
if res != nil {
|
||||
_ = res.Body.Close()
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
endpoint := ""
|
||||
var err error
|
||||
for _, ipserver := range iplist {
|
||||
client := &http.Client{
|
||||
Timeout: time.Second * 10,
|
||||
}
|
||||
|
||||
var resp *http.Response
|
||||
resp, err = client.Get(ipserver)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
bodies = append(bodies, resp)
|
||||
defer resp.Body.Close()
|
||||
if resp.StatusCode == http.StatusOK {
|
||||
var bodyBytes []byte
|
||||
bodyBytes, err = io.ReadAll(resp.Body)
|
||||
|
Reference in New Issue
Block a user