Skip to content

Commit

Permalink
No need to use defer Close when we ReadAll
Browse files Browse the repository at this point in the history
  • Loading branch information
mat committed Nov 16, 2015
1 parent 7a6953a commit 00c8ecd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions besticon/besticon.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ func fetchHTML(url string) ([]byte, *url.URL, error) {
}

b, e := ioutil.ReadAll(r.Body)
r.Body.Close()
if e != nil {
return nil, nil, e
}
defer r.Body.Close()
if len(b) == 0 {
return nil, nil, errors.New("besticon: empty response")
}
Expand Down Expand Up @@ -235,11 +235,11 @@ func fetchIconDetails(url string) Icon {
}

b, e := ioutil.ReadAll(response.Body)
response.Body.Close()
if e != nil {
i.Error = e
return i
}
defer response.Body.Close()

cfg, format, e := image.DecodeConfig(bytes.NewReader(b))
if e != nil {
Expand Down

0 comments on commit 00c8ecd

Please sign in to comment.