3 ms·
Any time you managed to get a response you must close the body via a defer resp.Body.Close() And if you're using json.Decoder on the response body then it's wo
by buro9 11y ago
Any time you managed to get a response you must close the body via a defer resp.Body.Close()
And if you're using json.Decoder on the response body then it's worth noting that if you know you're only receiving a single JSON object then draining the remainder of the body will allow connection re-use as otherwise the connection will be closed and not re-used: https://github.com/google/go-github/commit/e0ff7111b024fda991e457d975e0b73e1380f05f https://github.com/google/go-github/commit/e0ff7111b024fda99...
- omginternets 11y agoEven if I don't read the body?
- buro9 11y agoEven if you don't read the body.