Skip to content
Permalink
Browse files
Make closing the body a little more robust
And with that also a little more idiomatic
  • Loading branch information
Sander van Harmelen committed Oct 13, 2015
1 parent ae932b7 commit 7058e8c3836c4ad7478e4fcfe2bfb11375d3e9de
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
@@ -299,9 +299,9 @@ func (cs *CloudStackClient) newRequest(api string, params url.Values) (json.RawM
if err != nil {
return nil, err
}
defer resp.Body.Close()

b, err := ioutil.ReadAll(resp.Body)
resp.Body.Close()
if err != nil {
return nil, err
}
@@ -305,9 +305,9 @@ func (cs *CloudStackClient) newRequest(api string, params url.Values) (json.RawM
if err != nil {
return nil, err
}
defer resp.Body.Close()

b, err := ioutil.ReadAll(resp.Body)
resp.Body.Close()
if err != nil {
return nil, err
}
@@ -299,9 +299,9 @@ func (cs *CloudStackClient) newRequest(api string, params url.Values) (json.RawM
if err != nil {
return nil, err
}
defer resp.Body.Close()

b, err := ioutil.ReadAll(resp.Body)
resp.Body.Close()
if err != nil {
return nil, err
}
@@ -390,9 +390,9 @@ func (as *allServices) GeneralCode() ([]byte, error) {
pn(" if err != nil {")
pn(" return nil, err")
pn(" }")
pn(" defer resp.Body.Close()")
pn("")
pn(" b, err := ioutil.ReadAll(resp.Body)")
pn(" resp.Body.Close()")
pn(" if err != nil {")
pn(" return nil, err")
pn(" }")

0 comments on commit 7058e8c

Please sign in to comment.