http.ClientIt does not require a special way to free up "used" resources. When it becomes unavailable, the memory used by it will be returned by the garbage collector.
http.ClientDoes not store connection or status information. The documentation even states that it http.Clientshould be reused:
( TCP-), , . .
, (, ) http.Client, , , Close() , , , Close() .
:
, , http.Client HTTP- (, Client.Do(), Client.Get(), Client.Post() ..), *http.Response, , , , Response.Body.Close(). doc http:
, :
resp, err := http.Get("http://example.com/")
if err != nil {
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
Client.Get():
err nil, resp non-nil resp.Body. Caller resp.Body, .