Y
Hacker News
new
|
ask
|
show
|
jobs
by
krf
4767 days 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 ?
2 comments
sauerbraten
4767 days ago
You're right. Fixed it, thanks!
link
realrocker
4767 days ago
Yup. It should be closed or it will probably leak memory in a few hours.
link
sauerbraten
4767 days ago
Not 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.
link