From 5abe8265b994f45b019168a827663e7fc2276371 Mon Sep 17 00:00:00 2001 From: Functionary Robot Date: Fri, 20 Apr 2018 14:04:15 +1000 Subject: [PATCH] itembase: fix errors found by vet Vet found the following errors: client.go:129: comparison of function Add != nil is always true client.go:183: comparison of function Add != nil is always true oauth.go:174: result of fmt.Errorf call not used A method in an interface can never be nil, so delete the needless checks. Don't discard the result of fmt.Errorf, log it. --- client.go | 16 ++++++---------- oauth.go | 2 +- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/client.go b/client.go index 91c0021..e5476f2 100644 --- a/client.go +++ b/client.go @@ -126,11 +126,9 @@ func (c *client) GetAllInto(destination interface { } for _, document := range response.Documents { - if destination.Add != nil { - err = destination.Add(document) - if err != nil { - log.Info("Error when adding document", "error", err) - } + err = destination.Add(document) + if err != nil { + log.Info("Error when adding document", "error", err) } } @@ -180,11 +178,9 @@ func (c *client) GetAllInto(destination interface { } for _, document := range response.Documents { - if destination.Add != nil { - destination.Add(document) - if err != nil { - log.Info("Error when adding document", "error", err) - } + destination.Add(document) + if err != nil { + log.Info("Error when adding document", "error", err) } } diff --git a/oauth.go b/oauth.go index 3074a50..b9254d7 100644 --- a/oauth.go +++ b/oauth.go @@ -171,7 +171,7 @@ func (c *client) getUserToken(userID string) (token *oauth2.Token) { _, err = client.Get(c.me) if err == nil { - fmt.Errorf("Fetch should return an error if no refresh token is set") + log.Printf("Fetch should return an error if no refresh token is set") } token, err = client.Transport.(*oauth2.Transport).Source.Token()