mirror of
https://github.com/gravitl/netmaker.git
synced 2024-11-10 17:48:25 +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:
parent
e878e4820a
commit
4c4cd6eb4d
1 changed files with 1 additions and 12 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue