Last active
November 8, 2019 10:00
-
-
Save chmike/fd007863a710075456f1bfbe2cff7cec to your computer and use it in GitHub Desktop.
Correct HTTP GET response handling
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
res, err := http.GET(...) | |
if res != nil { | |
defer func() { | |
_, err = io.Copy(ioutil.Discard, res.Body) | |
res.Body.Close() | |
}() | |
} | |
if err != nil { | |
// . . . | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Adding a timeout to Get. By default there is no timeout.