Update the canonical .golangci.yml for golangci-lint 2.x and check that each item does what it is meant to #142

Closed
opened 2026-11-03 21:27:14 +01:00 by clawbot · 2 comments
Collaborator

sneak, on #136 (comment):

yes. also update the go linter config for 2.x and check its syntax and that its configured items are doing what we intend them to (i understand a few are not)

The canonical file is .golangci.yml. Every Go repository vendors it, and prompts/REPO_POLICIES.md names the golangci-lint version it goes with.

Definition of done

  • .golangci.yml is up to date for the newest golangci-lint 2.x and passes that release's own syntax check.
  • Each configured item has been tried with the real golangci-lint 2.x in Docker against a sample repository, and does what it is meant to.
  • This issue records each item that did not do what was intended, and what changed.
  • Any finding the stricter config produces in this repository's own files is fixed in the same PR.

Model: opus-5-5

sneak, on https://git.eeqj.de/sneak/prompts/issues/136#issuecomment-165193: > yes. also update the go linter config for 2.x and check its syntax and that its configured items are doing what we intend them to (i understand a few are not) The canonical file is `.golangci.yml`. Every Go repository vendors it, and `prompts/REPO_POLICIES.md` names the golangci-lint version it goes with. **Definition of done** - `.golangci.yml` is up to date for the newest golangci-lint 2.x and passes that release's own syntax check. - Each configured item has been tried with the real golangci-lint 2.x in Docker against a sample repository, and does what it is meant to. - This issue records each item that did not do what was intended, and what changed. - Any finding the stricter config produces in this repository's own files is fixed in the same PR. Model: opus-5-5
clawbot self-assigned this 2026-11-03 21:27:14 +01:00
Author
Collaborator

Implementer's brief:

Version. The newest 2.x is v2.15.0, digest sha256:fbfcfd12a6f8d7f1b97b3362ca80fc2a244d46863148c73cb88e7793af96c481 (confirm it). The unmerged branch golangci-lint-v2.15.0, commit b910a1e, already moves the pin and brings canonicalheader back, and its message gives the proof. Use it as a starting point, after checking it, on a new branch cut from next. .golangci.yml and the pin in prompts/REPO_POLICIES.md change in one commit.

Syntax. Run that release's golangci-lint config verify once, by hand. This adds no config check step to any gate (sneak's ruling on #40) and no test or script to this repository.

Each item. Use a scratch Go module outside the clone, run with docker run --rm on the digest above. For each item, plant a case that must be caught and one that must not:

  • run.timeout and run.modules-download-mode.
  • default: all, enable and disable: every name exists in this release, the enabled set is what the comments say, and make lint would print no deprecation warning.
  • lll, funlen, cyclop and dupl: one case at the limit and one just over it.
  • depguard test-support: a plain file importing net/http/httptest is caught; a _test.go file and a file in a directory ending in test are not. Check that a parent directory ending in test behaves as the comment says, and that a repository's added deny entry works.
  • gomodguard_v2: every blocked module is caught and names its recommendation; github.com/go-redis/redismock and github.com/redis/go-redis/v9 are not.
  • exclusions: the local replace of github.com/grafana/sobek is accepted, another local replace is still refused, and the path and text patterns match what the linter really prints.
  • max-issues-per-linter and max-same-issues: more findings than the default limits are all reported.
  • No formatters section: say whether golangci-lint run checks formatting at all, and whether anything else does for a Go repository. Linters that default: all turned on under 1.x may no longer run.
  • Every comment in the file is true.

Changes. Fix what fails. A new disable or a loosened limit needs a reason in the file and a line on this issue. A choice only the owner can make goes on the PR with the reading you took.

Record. One comment here: each item that did not do what was intended and what changed. Nothing about items that passed. This repository has no Go files, so a finding in its own files is unlikely; the docs must still agree with the new config (REPO_POLICIES.md, the checklists and prompts/CODE_STYLEGUIDE_GO.md).

Model: opus-5-5

Implementer's brief: **Version.** The newest 2.x is v2.15.0, digest `sha256:fbfcfd12a6f8d7f1b97b3362ca80fc2a244d46863148c73cb88e7793af96c481` (confirm it). The unmerged branch `golangci-lint-v2.15.0`, commit `b910a1e`, already moves the pin and brings `canonicalheader` back, and its message gives the proof. Use it as a starting point, after checking it, on a new branch cut from `next`. `.golangci.yml` and the pin in `prompts/REPO_POLICIES.md` change in one commit. **Syntax.** Run that release's `golangci-lint config verify` once, by hand. This adds no config check step to any gate (sneak's ruling on https://git.eeqj.de/sneak/prompts/issues/40) and no test or script to this repository. **Each item.** Use a scratch Go module outside the clone, run with `docker run --rm` on the digest above. For each item, plant a case that must be caught and one that must not: - `run.timeout` and `run.modules-download-mode`. - `default: all`, `enable` and `disable`: every name exists in this release, the enabled set is what the comments say, and `make lint` would print no deprecation warning. - `lll`, `funlen`, `cyclop` and `dupl`: one case at the limit and one just over it. - `depguard` `test-support`: a plain file importing `net/http/httptest` is caught; a `_test.go` file and a file in a directory ending in `test` are not. Check that a parent directory ending in `test` behaves as the comment says, and that a repository's added `deny` entry works. - `gomodguard_v2`: every blocked module is caught and names its recommendation; `github.com/go-redis/redismock` and `github.com/redis/go-redis/v9` are not. - `exclusions`: the local `replace` of `github.com/grafana/sobek` is accepted, another local `replace` is still refused, and the path and text patterns match what the linter really prints. - `max-issues-per-linter` and `max-same-issues`: more findings than the default limits are all reported. - No `formatters` section: say whether `golangci-lint run` checks formatting at all, and whether anything else does for a Go repository. Linters that `default: all` turned on under 1.x may no longer run. - Every comment in the file is true. **Changes.** Fix what fails. A new `disable` or a loosened limit needs a reason in the file and a line on this issue. A choice only the owner can make goes on the PR with the reading you took. **Record.** One comment here: each item that did not do what was intended and what changed. Nothing about items that passed. This repository has no Go files, so a finding in its own files is unlikely; the docs must still agree with the new config (`REPO_POLICIES.md`, the checklists and `prompts/CODE_STYLEGUIDE_GO.md`). Model: opus-5-5
Author
Collaborator

What did not do what was intended, and what changed in #144:

  • canonicalheader was off, because v2.14.0 misses findings at random. v2.15.0 fixes that, so it is on again.
  • depguard test-support exempted too much. !**/*test/** matched everything below a directory ending in test, not only that package. It also matched a directory above the checkout, so a repository linted under .../mytest/app reported nothing at all. The pattern is now !${base-path}**/*test/*. It exempts only the files directly inside such a directory, and the directory a repository is cloned into does not count.
  • gomodguard_v2 missed a pre-fork path. github.com/go-redis/redis/v9 has pre-releases that can still be imported, such as v9.0.0-rc.1. It now has an entry. The older gopkg.in/redis.vN paths are not listed.
  • uniq-by-line kept its default, so a line that tripped two linters printed one finding, despite max-issues-per-linter: 0 and max-same-issues: 0. It is now false, and such a line reports both findings.
  • Formatting: .golangci.yml has no formatters section, so golangci-lint run does not run gofmt. gofmt, gofumpt, goimports and gci became formatters in 2.x, so default: all no longer turns them on. A Go repository's own script/fmt-check runs gofmt, on the host. A comment in the file now says so. No formatters section was added, on sneak's ruling at #40 (comment).
  • Comments that were wrong:
    • "Only decisions already recorded in the Go package defaults" was untrue. That file on this host records zerolog but not the go-redis or diff modules, so the claim is gone.
    • exhaustruct is deprecated but was not in the deprecated group, so it moved there.
    • github.com/go-redis/redismock has no published version, so the comment now names /v9.

No new disable entry and no loosened limit.

Model: opus-5-5

What did not do what was intended, and what changed in https://git.eeqj.de/sneak/prompts/pulls/144: - **`canonicalheader`** was off, because v2.14.0 misses findings at random. v2.15.0 fixes that, so it is on again. - **`depguard` `test-support`** exempted too much. `!**/*test/**` matched everything below a directory ending in `test`, not only that package. It also matched a directory above the checkout, so a repository linted under `.../mytest/app` reported nothing at all. The pattern is now `!${base-path}**/*test/*`. It exempts only the files directly inside such a directory, and the directory a repository is cloned into does not count. - **`gomodguard_v2`** missed a pre-fork path. `github.com/go-redis/redis/v9` has pre-releases that can still be imported, such as `v9.0.0-rc.1`. It now has an entry. The older `gopkg.in/redis.vN` paths are not listed. - **`uniq-by-line`** kept its default, so a line that tripped two linters printed one finding, despite `max-issues-per-linter: 0` and `max-same-issues: 0`. It is now `false`, and such a line reports both findings. - **Formatting**: `.golangci.yml` has no `formatters` section, so `golangci-lint run` does not run `gofmt`. `gofmt`, `gofumpt`, `goimports` and `gci` became formatters in 2.x, so `default: all` no longer turns them on. A Go repository's own `script/fmt-check` runs `gofmt`, on the host. A comment in the file now says so. No `formatters` section was added, on sneak's ruling at https://git.eeqj.de/sneak/prompts/issues/40#issuecomment-53663. - **Comments** that were wrong: - "Only decisions already recorded in the Go package defaults" was untrue. That file on this host records zerolog but not the go-redis or diff modules, so the claim is gone. - `exhaustruct` is deprecated but was not in the deprecated group, so it moved there. - `github.com/go-redis/redismock` has no published version, so the comment now names `/v9`. No new `disable` entry and no loosened limit. Model: opus-5-5
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/prompts#142