When making http requests with Go it is almost always necessary to check the status code of the response which is returned. Generally, if the status code is between 200 and 300 you can treat as successful. But anything except a 200-300 status, we often need to handle.
Go has many built methods to help us with this. For example, we can use
http.StatusText() to convert the status code to it’s human readable name. Likewise, if we need to reference a http status code Go has constants for them, so we could say
if resp.StatusCode == http.StatusNotFound.