Loading
chore(lint): enable modernize linter and fix its findings
Summary
Enables the modernize linter in .golangci.yml and fixes every finding it
reports: 31 across 15 files.
All of the code changes are mechanical and behavior-preserving. They are split
into one commit per modernize sub-check, so each can be reviewed as a single
kind of transformation:
any: replaceinterface{}withanyfmtappendf: replace[]byte(fmt.Sprintf(...))withfmt.Appendfmapsloop: replace map copy loops withmaps.Copystringsseq: range overstrings.SplitSeq/bytes.SplitSeqinstead ofSplitrangeint: range over an int instead of a countingforloopslicesbackward: useslices.Backwardfor reverse iterationnewexpr: makeclient.Ptran inlinable wrapper aroundnew(expr)
Why
- The repo moved to a Go 1.26 baseline in !549 (merged), which makes newer standard
library and language constructs available everywhere.
modernizefinds the call sites still written the older way. - Enabling the linter without fixing its findings would leave
make go-lintred, so both belong in the same change.
How
Two things a reviewer cannot pick up from the diff:
make go-lintunder-reports the findings. golangci-lint's defaultissues.max-same-issues: 3truncates each sub-check to three reports, so the command shows 17 of the 31. The full set comes fromgolangci-lint run --max-same-issues=0 --max-issues-per-linter=0 ./.... This MR leaves the default in place, so the same cap applies to future findings.client.Ptrdeliberately has no//go:fix inlinedirective. Thenewexprfix suggests adding one, which would havegoplsandgo fixrewrite everyclient.Ptr(x)call site tonew(x). Returningnew(v)on its own already satisfies the linter, and the directive would push a much wider change onto the callers of an exported helper, so it is left off.
One commit is not a clean single sub-check: the rangeint fix to
Environment.ValueOf's outer loop ships with the slicesbackward commit,
because the inner slices.Backward(env.mutations) rewrite depends on having the
element in hand rather than the index. Lock ordering in readLockEnvChain is
unchanged.
Related
- Follows the Go 1.26 baseline set in !549 (merged).