Skip to content

Instantly share code, notes, and snippets.

@sidneyw
Created August 6, 2019 03:45
Show Gist options
  • Save sidneyw/999ccdd2770a84a325148fe459b0fd78 to your computer and use it in GitHub Desktop.
Save sidneyw/999ccdd2770a84a325148fe459b0fd78 to your computer and use it in GitHub Desktop.
func parseResponse(res *http.Response, unmarshalStruct interface{}) error {
body, err := ioutil.ReadAll(res.Body)
if err != nil {
return err
}
res.Body.Close()
res.Body = ioutil.NopCloser(bytes.NewBuffer(body))
return json.Unmarshal(body, unmarshalStruct)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment