I found in request.go:
func (r *Request) Send(c *http.Client) (*Response, error) {
// snip
if resp.StatusCode >= http.StatusBadRequest {
// snip
io.Copy(ioutil.Discard, resp.Body)
resp.Body.Close()
}
}
when developer use go-ipfs-api, they typically:
// var shells []*shell.Shell = ... connection to a lot of ipfs nodes..
localFile, err := os.Open(localfPath)
defer localFile.Close()
if err != nil {
return nil, err
}
err = retry.Retry(func(attempt uint) error {
response, err = shells[attempt].Add(localFile)
if err != nil {
return err
}
return nil
},
strategy.Limit(limit),
)
So when fail on one shell.add, shell will close the file it pass, it's not good. The close of file should leave to developer.