-
-
Save sidneyw/999ccdd2770a84a325148fe459b0fd78 to your computer and use it in GitHub Desktop.
This file contains 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
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