Skip to content

Commit 5111b3b

Browse files
authored
Merge pull request #32 from msiuts/fix_defer_body_close
handle http error before closing the body
2 parents 7ec4b4e + a257568 commit 5111b3b

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

exporter/gather.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,10 @@ func getRates(baseURL string, token string) (*RateLimits, error) {
5656
url := fmt.Sprintf("%s%s", baseURL, rateEndPoint)
5757

5858
resp, err := getHTTPResponse(url, token)
59-
60-
defer resp.Body.Close()
61-
6259
if err != nil {
6360
return &RateLimits{}, err
6461
}
62+
defer resp.Body.Close()
6563

6664
// Triggers if rate-limiting isn't enabled on private Github Enterprise installations
6765
if resp.StatusCode == 404 {

0 commit comments

Comments
 (0)