I'm not entirely sure of this, as checkHTTPStatus doesn't actually read anything from the body, but you might want to defer resp.Body.Close()here.
Go docs for net/http say:
Callers should close resp.Body when done reading from it. If resp.Body is not closed, the Client's underlying RoundTripper (typically Transport) may not be able to re-use a persistent TCP connection to the server for a subsequent "keep-alive" request.
Basically, I think the code as it is now might leave TCP connections open (at least until they're killed by the server). I haven't actually tested it yet though.
And as we're not reading anything from the Body, we're "done reading from it" immediately after the request has been returned, I guess.
I'm not entirely sure of this, as
checkHTTPStatus
doesn't actually read anything from the body, but you might want todefer resp.Body.Close()
here.Go docs for
net/http
say:Basically, I think the code as it is now might leave TCP connections open (at least until they're killed by the server). I haven't actually tested it yet though.
And as we're not reading anything from the Body, we're "done reading from it" immediately after the request has been returned, I guess.