7 ms·
I'm new to Go but shouldn't the defer rawResp.Body.Close() be done after the error checking. If there is an error wouldn't rawResp be nil ?
by krf 13y ago
I'm new to Go but shouldn't the defer rawResp.Body.Close() be done after the error checking. If there is an error wouldn't rawResp be nil ?
- sauerbraten 13y agoYou're right. Fixed it, thanks!
- realrocker 13y agoYup. It should be closed or it will probably leak memory in a few hours.
- sauerbraten 13y agoNot really. Memory would only be leaked if there really was an error and rawResp was still nil. Since this usually doesn't happen (at least it never happened to me), you probably wouldn't even have noticed this bug.