Skip to content
This repository has been archived by the owner on Apr 30, 2020. It is now read-only.

Commit

Permalink
fix golint 'using resp before checking for errors'
Browse files Browse the repository at this point in the history
  • Loading branch information
WolfgangMau committed Jan 29, 2018
1 parent c79fa0c commit 6f93801
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions internal/helper/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@ func GetToken(clientID, clientSecret, code string) (*TokenResponse, error) {
val.Add("code", code)

resp, err := http.PostForm("https://www.googleapis.com/oauth2/v3/token", val)
defer resp.Body.Close()
if err != nil {
return nil, err
}
defer resp.Body.Close()

tr := &TokenResponse{}
err = json.NewDecoder(resp.Body).Decode(tr)
if err != nil {
Expand Down Expand Up @@ -96,10 +97,11 @@ func GetUserEmail(accessToken string) (string, error) {
q.Set("access_token", accessToken)
uri.RawQuery = q.Encode()
resp, err := http.Get(uri.String())
defer resp.Body.Close()
if err != nil {
return "", err
}
defer resp.Body.Close()

ui := &UserInfo{}
err = json.NewDecoder(resp.Body).Decode(ui)
if err != nil {
Expand Down

0 comments on commit 6f93801

Please sign in to comment.