As in many golang net/http
articles, a request returns two values: response and error:
resp, err := http.Get("http://example.com/")
if err != nil {
// handle error
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
For http-related errors, it will be returned in resp
with status code like 502, 400 etc. What are the possible errors returned? I need to know them before I can handle them.