diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 75a267ace..e6cb88482 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -31,6 +31,5 @@ jobs: - name: Lint uses: golangci/golangci-lint-action@v6 with: - version: v1.60.3 - working-directory: ${{ matrix.workdir }} - skip-pkg-cache: true + version: v1.61.0 + working-directory: ${{ matrix.workdir }} \ No newline at end of file diff --git a/.golangci.yml b/.golangci.yml index 57b20dd76..5e7c6d23e 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -10,8 +10,9 @@ linters: - dogsled - durationcheck - errcheck - - exportloopref + # - copyloopvar # need upgrade to Go 1.22 - govet + - staticcheck - gosimple - gofmt - gofumpt @@ -49,7 +50,8 @@ linters: linters-settings: govet: - check-shadowing: true + enable: + - shadow whitespace: multi-func: true lll: diff --git a/app.go b/app.go index 86a6cb5bf..bb406aaca 100644 --- a/app.go +++ b/app.go @@ -99,17 +99,17 @@ func (a *App) Run() error { } } for _, srv := range a.opts.servers { - srv := srv + server := srv eg.Go(func() error { <-ctx.Done() // wait for stop signal stopCtx, cancel := context.WithTimeout(NewContext(a.opts.ctx, a), a.opts.stopTimeout) defer cancel() - return srv.Stop(stopCtx) + return server.Stop(stopCtx) }) wg.Add(1) eg.Go(func() error { wg.Done() // here is to ensure server start has begun running before register, so defer is not needed - return srv.Start(NewContext(a.opts.ctx, a)) + return server.Start(NewContext(a.opts.ctx, a)) }) } wg.Wait() diff --git a/contrib/registry/consul/registry_test.go b/contrib/registry/consul/registry_test.go index bb0aeef01..8133c55c5 100644 --- a/contrib/registry/consul/registry_test.go +++ b/contrib/registry/consul/registry_test.go @@ -584,7 +584,7 @@ func TestRegistry_IdleAndWatch2(t *testing.T) { if err1 != nil { t.Error(err1) } - go func(i int) { + go func(_ int) { // first service, err2 := watch.Next() if (err2 != nil) != tt.wantErr { diff --git a/transport/grpc/client.go b/transport/grpc/client.go index 359f56cf4..42ad5d724 100644 --- a/transport/grpc/client.go +++ b/transport/grpc/client.go @@ -254,7 +254,7 @@ func (w *wrappedClientStream) Context() context.Context { } func (w *wrappedClientStream) SendMsg(m interface{}) error { - h := func(ctx context.Context, req interface{}) (interface{}, error) { + h := func(_ context.Context, req interface{}) (interface{}, error) { return req, w.ClientStream.SendMsg(m) } @@ -272,7 +272,7 @@ func (w *wrappedClientStream) SendMsg(m interface{}) error { } func (w *wrappedClientStream) RecvMsg(m interface{}) error { - h := func(ctx context.Context, req interface{}) (interface{}, error) { + h := func(_ context.Context, req interface{}) (interface{}, error) { return req, w.ClientStream.RecvMsg(m) } @@ -305,7 +305,7 @@ func streamClientInterceptor(ms []middleware.Middleware, filters []selector.Node return nil, err } - h := func(ctx context.Context, req interface{}) (interface{}, error) { + h := func(_ context.Context, _ interface{}) (interface{}, error) { return streamer, nil } diff --git a/transport/grpc/interceptor.go b/transport/grpc/interceptor.go index 6261442d6..f84b4bcfc 100644 --- a/transport/grpc/interceptor.go +++ b/transport/grpc/interceptor.go @@ -80,7 +80,7 @@ func (s *Server) streamServerInterceptor() grpc.StreamServerInterceptor { replyHeader: headerCarrier(replyHeader), }) - h := func(ctx context.Context, req interface{}) (interface{}, error) { + h := func(_ context.Context, _ interface{}) (interface{}, error) { return handler(srv, ss), nil }