From 6459a000fba0993ec553b8748ab586de20e95c43 Mon Sep 17 00:00:00 2001 From: Daniel White Date: Wed, 23 Jul 2025 19:40:27 +1000 Subject: [PATCH 1/2] Linter configuration for golangci-lint added This is motivated by #89 to document the target baseline for linting. It intentionally avoids enforcing linting for changes prior to the introduction of this configuration so that the project can be incrementally brought in line. Each linter is explicitly enabled so there are no surprises if the defaults are changed. Only simple formatters are included since the needs of this project are relatively simple. --- .golangci.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .golangci.yml diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..6f9b7b0 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,23 @@ +# Configuration of formatting and linting using https://golangci-lint.run/. +version: "2" + +linters: + default: none + enable: + - errcheck + - govet + - ineffassign + - staticcheck + - unused + +formatters: + enable: + - gofmt + - goimports + +issues: + # Show only new issues created after the introduction of the linter. + new-from-rev: ea5ac7e13561f6334938261321e13a725d1c0180 + + # Show issues in any part of update files (requires new-from-rev or new-from-patch). + whole-files: true From c3c8723d15dc3b75a34552812b074c100c920752 Mon Sep 17 00:00:00 2001 From: Daniel White Date: Wed, 23 Jul 2025 23:37:57 +1000 Subject: [PATCH 2/2] GitHub Actions workflow to run golangci-lint added This workflow derives from the recommendation [1] to run a separate linting job in parallel with other jobs (i.e. tests). Only new issues will be included until the rest of the repository has been brought up to date with the new linting rules. [1]: https://github.com/golangci/golangci-lint-action?tab=readme-ov-file#how-to-use --- .github/workflows/golangci-lint.yml | 31 +++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/golangci-lint.yml diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml new file mode 100644 index 0000000..39f0045 --- /dev/null +++ b/.github/workflows/golangci-lint.yml @@ -0,0 +1,31 @@ +name: Lint +on: + push: + branches: + - master + pull_request: + branches: + - master + +permissions: + contents: read + +jobs: + golangci: + name: lint + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version: stable + + - name: golangci-lint + uses: golangci/golangci-lint-action@v8 + with: + version: v2.1 + # Show only new issues until the entire repository + # is compliant with the new linting rules. + only-new-issues: true