diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c331fb7..f9ad514 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,10 +10,10 @@ jobs: strategy: matrix: - go-version: [ "1.24", "1.25" ] + go-version: [ "1.25", "1.26" ] runs-on: ubuntu-latest env: - GOLANGCI_LINT_VERSION: v2.4.0 + GOLANGCI_LINT_VERSION: v2.9.0 steps: - name: Checkout code diff --git a/.golangci.yml b/.golangci.yml index 413962a..28b30b9 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -47,6 +47,14 @@ linters: max-complexity: 15 funlen: lines: 160 + revive: + rules: + - name: var-naming + arguments: + - [] + - [] + - - skip-package-name-checks: true + skip-package-name-collision-with-go-std: true exclusions: generated: lax rules: diff --git a/errors/reason/reason.go b/errors/reason/reason.go index a8e8348..99f9380 100644 --- a/errors/reason/reason.go +++ b/errors/reason/reason.go @@ -38,10 +38,8 @@ func Extract(err error) ([]string, error) { //nolint:errorlint // This is the only way to check for the interface. switch x := err.(type) { case interface{ Unwrap() []error }: - var ( - reasons []string - errs []error - ) + reasons := make([]string, 0, len(x.Unwrap())) + var errs []error for _, err = range x.Unwrap() { r, e := Extract(err) reasons = append(reasons, r...) diff --git a/go.mod b/go.mod index a8ab192..70b1527 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,6 @@ module github.com/hamba/pkg/v2 -go 1.24.0 - -toolchain go1.24.1 +go 1.25.0 require ( github.com/hamba/logger/v2 v2.9.0 diff --git a/http/middleware/middleware_test.go b/http/middleware/middleware_test.go index 635ee55..cc3734c 100644 --- a/http/middleware/middleware_test.go +++ b/http/middleware/middleware_test.go @@ -25,7 +25,7 @@ func TestRecovery(t *testing.T) { tests := []struct { name string - val interface{} + val any wantLog string }{ { diff --git a/wait/wait_test.go b/wait/wait_test.go index dbfa1fc..a5c00b7 100644 --- a/wait/wait_test.go +++ b/wait/wait_test.go @@ -43,8 +43,7 @@ func TestPollUntil(t *testing.T) { } func TestPollUntil_HandlesError(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() + ctx := t.Context() var count int err := wait.PollUntil(ctx, func(context.Context) (done bool, err error) { @@ -59,8 +58,7 @@ func TestPollUntil_HandlesError(t *testing.T) { } func TestPollUntil_HandlesDone(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() + ctx := t.Context() var count int err := wait.PollUntil(ctx, func(context.Context) (done bool, err error) { @@ -107,8 +105,7 @@ func TestPollImmediateUntil(t *testing.T) { } func TestPollImmediateUntil_HandlesImmediateError(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() + ctx := t.Context() err := wait.PollImmediateUntil(ctx, func(context.Context) (done bool, err error) { return false, errors.New("test") @@ -118,8 +115,7 @@ func TestPollImmediateUntil_HandlesImmediateError(t *testing.T) { } func TestPollImmediateUntil_HandlesImmediateDone(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() + ctx := t.Context() err := wait.PollImmediateUntil(ctx, func(context.Context) (done bool, err error) { return true, nil