diff --git a/auth/jwt/transport_test.go b/auth/jwt/transport_test.go index 83d0f17f8..f20055be2 100644 --- a/auth/jwt/transport_test.go +++ b/auth/jwt/transport_test.go @@ -76,7 +76,7 @@ func TestGRPCToContext(t *testing.T) { } // Invalid Authorization header is passed - md["authorization"] = []string{fmt.Sprintf("%s", signedKey)} + md["authorization"] = []string{signedKey} ctx = reqFunc(context.Background(), md) token = ctx.Value(JWTTokenContextKey) if token != nil { diff --git a/cmd/kitgen/path_test.go b/cmd/kitgen/path_test.go index 818d89cd7..10a71cfe0 100644 --- a/cmd/kitgen/path_test.go +++ b/cmd/kitgen/path_test.go @@ -40,7 +40,7 @@ func TestImportPathSadpath(t *testing.T) { if actual != "" { t.Errorf("Expected empty path, got %q", actual) } - if strings.Index(err.Error(), expected) == -1 { + if !strings.Contains(err.Error(), expected) { t.Errorf("Expected %q to include %q", err, expected) } }) diff --git a/cmd/kitgen/transform.go b/cmd/kitgen/transform.go index a66ff96da..112fe38b3 100644 --- a/cmd/kitgen/transform.go +++ b/cmd/kitgen/transform.go @@ -59,7 +59,7 @@ func importPath(targetDir, gopath string) (string, error) { if err != nil { continue } - if strings.Index(res, "..") == -1 { + if !strings.Contains(res, "..") { return res, nil } } diff --git a/log/sync_test.go b/log/sync_test.go index 253f256d1..fd7cdfd0f 100644 --- a/log/sync_test.go +++ b/log/sync_test.go @@ -58,8 +58,7 @@ func TestSwapLoggerConcurrency(t *testing.T) { } func TestSyncLoggerConcurrency(t *testing.T) { - var w io.Writer - w = &bytes.Buffer{} + var w io.Writer = &bytes.Buffer{} logger := log.NewLogfmtLogger(w) logger = log.NewSyncLogger(logger) testConcurrency(t, logger, 10000) diff --git a/metrics/generic/generic.go b/metrics/generic/generic.go index b69334507..39216c04f 100644 --- a/metrics/generic/generic.go +++ b/metrics/generic/generic.go @@ -182,7 +182,7 @@ func (h *Histogram) LabelValues() []string { func (h *Histogram) Print(w io.Writer) { h.h.RLock() defer h.h.RUnlock() - fmt.Fprintf(w, h.h.String()) + fmt.Fprint(w, h.h.String()) } // safeHistogram exists as gohistogram.Histogram is not goroutine-safe. diff --git a/sd/etcd/client_test.go b/sd/etcd/client_test.go index 1bdb7aee9..e53565e9c 100644 --- a/sd/etcd/client_test.go +++ b/sd/etcd/client_test.go @@ -1,11 +1,11 @@ package etcd import ( + "context" "errors" "reflect" "testing" "time" - "context" etcd "go.etcd.io/etcd/client" ) @@ -135,7 +135,7 @@ func (fw *fakeWatcher) Next(context.Context) (*etcd.Response, error) { return nil, nil case <-fw.err: return nil, errors.New("error from underlying etcd watcher") - default: + } } } diff --git a/sd/zk/client_test.go b/sd/zk/client_test.go index e201536d8..f335ab4d3 100644 --- a/sd/zk/client_test.go +++ b/sd/zk/client_test.go @@ -63,7 +63,7 @@ func TestNewClient(t *testing.T) { if want, have := sessionTimeout, clientImpl.sessionTimeout; want != have { t.Errorf("want %d, have %d", want, have) } - if want, have := payload, clientImpl.rootNodePayload; bytes.Compare(want[0], have[0]) != 0 || bytes.Compare(want[1], have[1]) != 0 { + if want, have := payload, clientImpl.rootNodePayload; !bytes.Equal(want[0], have[0]) || !bytes.Equal(want[1], have[1]) { t.Errorf("want %s, have %s", want, have) } diff --git a/transport/http/proto/proto_test.go b/transport/http/proto/proto_test.go index 7b59d71a2..070bbec02 100644 --- a/transport/http/proto/proto_test.go +++ b/transport/http/proto/proto_test.go @@ -1,6 +1,7 @@ package proto import ( + "context" "io/ioutil" "net/http" "net/http/httptest" @@ -14,7 +15,7 @@ func TestEncodeProtoRequest(t *testing.T) { r := httptest.NewRequest(http.MethodGet, "/cat", nil) - err := EncodeProtoRequest(nil, r, cat) + err := EncodeProtoRequest(context.TODO(), r, cat) if err != nil { t.Errorf("expected no encoding errors but got: %s", err) return @@ -51,7 +52,7 @@ func TestEncodeProtoResponse(t *testing.T) { wr := httptest.NewRecorder() - err := EncodeProtoResponse(nil, wr, cat) + err := EncodeProtoResponse(context.TODO(), wr, cat) if err != nil { t.Errorf("expected no encoding errors but got: %s", err) return