Loop1:
for {
resp, err = http.Get(url)
defer resp.Body.Close()
if err != nil {
logger.Info(err)
} else {
body, err = ioutil.ReadAll(resp.Body)
if resp.StatusCode == 200 {
break Loop1
}
logger.Info(err)
}
logger.Info(err)
time.Sleep( 5 * time.Second)
}
老师,for循环里这样写defer,goland会提示可能发生资源泄露,应该怎么写更合理一点呢