From bf0f4c862199351928391a5f4922db718324ca1a Mon Sep 17 00:00:00 2001 From: Abhinav Gupta Date: Sun, 1 Jun 2025 11:16:17 -0700 Subject: [PATCH] Update to golangci-lint v2, Go 1.24 Change CI to test with Go 1.24 and drop 1.21. Migrate the golangci-lint config to v2 format as that's the default for the golangci-lint GitHub Action now. --- .github/workflows/ci.yml | 10 ++--- .golangci.yml | 90 ++++++++++++++++++++-------------------- 2 files changed, 50 insertions(+), 50 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 014a52e..8902174 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,16 +30,16 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - go-version: ['1.23.x', '1.22.x', '1.21.x'] + go-version: ['1.24.x', '1.23.x', '1.22.x'] arch: ['amd64', '386', 'arm64'] os: ['ubuntu-latest'] include: - os: 'macos-latest' arch: 'amd64' - go-version: '1.23.x' + go-version: '1.24.x' - os: 'windows-latest' arch: 'amd64' - go-version: '1.23.x' + go-version: '1.24.x' steps: - name: Checkout code @@ -95,14 +95,14 @@ jobs: go-version-file: go.mod cache: false # managed by golangci-lint - - uses: golangci/golangci-lint-action@v6 + - uses: golangci/golangci-lint-action@v8 name: Install golangci-lint with: version: latest args: --help # make lint will run the linter - name: Lint - run: make lint GOLANGCI_LINT_ARGS=--out-format=github-actions + run: make lint # Write in a GitHub Actions-friendly format # to annotate lines in the PR. diff --git a/.golangci.yml b/.golangci.yml index eadc334..e5f8f80 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,59 +1,59 @@ -output: - # Make output more digestible with quickfix in vim/emacs/etc. - sort-results: true - print-issued-lines: false +version: "2" + +# Print all issues reported by all linters. +issues: + max-issues-per-linter: 0 + max-same-issues: 0 linters: # We'll track the golangci-lint default linters manually # instead of letting them change without our control. - disable-all: true + default: none enable: # golangci-lint defaults: - errcheck - - gosimple - govet - ineffassign - staticcheck - unused # Our own extras: - - gofumpt - - nolintlint # lints nolint directives - revive - -linters-settings: - govet: - # These govet checks are disabled by default, but they're useful. - enable: - - niliness - - reflectvaluecompare - - sortslice - - unusedwrite - - errcheck: - exclude-functions: - # Writing a plain string to a fmt.State cannot fail. - - io.WriteString(fmt.State) - - fmt.Fprintf(fmt.State) - -issues: - # Print all issues reported by all linters. - max-issues-per-linter: 0 - max-same-issues: 0 - - # Don't ignore some of the issues that golangci-lint considers okay. - # This includes documenting all exported entities. - exclude-use-default: false - - exclude-rules: - # Don't warn on unused parameters. - # Parameter names are useful; replacing them with '_' is undesirable. - - linters: [revive] - text: 'unused-parameter: parameter \S+ seems to be unused, consider removing or renaming it as _' - - # staticcheck already has smarter checks for empty blocks. - # revive's empty-block linter has false positives. - # For example, as of writing this, the following is not allowed. - # for foo() { } - - linters: [revive] - text: 'empty-block: this block is empty, you can remove it' + - nolintlint + + settings: + + errcheck: + exclude-functions: + # Writing a plain string to a fmt.State cannot fail. + - io.WriteString(fmt.State) + - fmt.Fprintf(fmt.State) + + govet: + # These govet checks are disabled by default, but they're useful. + enable: + - nilness + - reflectvaluecompare + - sortslice + - unusedwrite + + exclusions: + generated: lax + rules: + # Don't warn on unused parameters. + # Parameter names are useful; replacing them with '_' is undesirable. + - linters: [revive] + text: 'unused-parameter: parameter \S+ seems to be unused, consider removing or renaming it as _' + + # staticcheck already has smarter checks for empty blocks. + # revive's empty-block linter has false positives. + # For example, as of writing this, the following is not allowed. + # for foo() { } + - linters: [revive] + text: 'empty-block: this block is empty, you can remove it' + +formatters: + enable: + - gofumpt + exclusions: + generated: lax