Defer body.close after receiving response

go

Solution

Quoting from the official documentation of the http package:

The client must close the response body when finished with it

Problem

``` ...... resp, err := httplib.Get(url) if err != nil { fmt.Println(err) } defer resp.Body.Close() ...... ``` Is it necessary to close the response body every time?

Original source