diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fc8ca8f..fc5e0c4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,11 +1,19 @@ repos: - - repo: https://github.com/golangci/golangci-lint.git - rev: v2.12.0 - hooks: - - id: golangci-lint - args: [--fix] - repo: local hooks: + # Uses the golangci-lint on PATH rather than the upstream pre-commit + # repo, which builds the linter from source with whatever Go it finds. + # A linter built with Go < 1.26 refuses to load this config ("the Go + # language version used to build golangci-lint is lower than the + # targeted Go version"). Install the matching binary with: + # go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.12.0 + - id: golangci-lint + name: golangci-lint + entry: golangci-lint run --fix + language: system + types: [go] + pass_filenames: false + require_serial: true - id: go-test name: go test entry: go test ./... diff --git a/CLAUDE.md b/CLAUDE.md index 83db91b..a4074e6 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -18,7 +18,13 @@ pre-commit run --all-files # lint+test against the whole tree ~/go/bin/golangci-lint run # lint without pre-commit (needs v2.12+) ``` -`pre-commit install` was already run in this clone — every commit runs golangci-lint (with `--fix`) and `go test ./...`. The hooks pin golangci-lint v2.12.0; CI pins the same version through `golangci/golangci-lint-action@v7`. +`pre-commit install` was already run in this clone — every commit runs golangci-lint (with `--fix`) and `go test ./...`. The lint hook shells out to the `golangci-lint` on `PATH` instead of the upstream pre-commit repo, which builds the linter from source with whatever Go it finds; a linter built with Go < 1.26 refuses to load this config. Install the matching binary once: + +```bash +go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.12.0 +``` + +CI pins the same version through `golangci/golangci-lint-action@v7`. ## Architecture