In Go, I have some http responses and I sometimes forget to call:
resp.Body.Close()
What happens in this case? will there be a memory leak
At first the descriptor never closes, as things mentioned above.
And what's more, golang will cache the connection (using persistConn struct to wrap) for reusing it, if DisableKeepAlives is false.
In golang after use client.Do method, go will run goroutine readLoop method as one of the step.
So in golang http transport.go, a pconn(persistConn struct) won't be put into idleConn channel until the req canceled in the readLoop method, and also this goroutine(readLoop method) will be blocked until the req canceled.
Here is the code showing it.
If you want to know more, you need to see the readLoop method.