refactor: run the Go 1.27 modernizer (go fix) - #8
Merged
Merged
Conversation
Applied with the two analyzers this org declines disabled:
go fix -embedlit=false -omitzero=false ./...
slicescontains and slicesbackward rewrites only; every hunk is behaviour-identical.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tool
The Go 1.27 modernizer —
cmd/fix, driven bygo fix, from the repo's own pinnedtoolchain (
go 1.27.0ingo.mod):On Go 1.27
go fix ./...is the modernizer and applies its rewrites in place;go fix -diff ./...prints them instead, which is how every hunk below was readbefore it was kept.
Excluded analyzers
Run exactly as:
embedlitflattensCoordinates: sdk.Coordinates{...}into the bare promotedfields at construction sites. It is behaviour-identical, so nothing mechanical
objects — which is why the decision has to be written down.
Coordinatesis a namedidentity concept (ADR-0041) and the wrapper is what makes that identity visible at a
construction site.
bomly-cliandbomly-sdkboth decline it; these repos agree.Verified here:
go fix -embedlit -diff ./...is empty in this repo, so the flag isbelt-and-braces rather than load-bearing — it stays on the command line so the next
run cannot regress.
omitzerorewritesomitemptytoomitzeroon struct-valued JSON fields. Theencoded bytes do not move —
encoding/jsonnever omits a struct — so no test and noAPI gate objects, but the tag is the wire schema for
bomly.plugin.v1, and areflection-based schema consumer then reads the field as required.
bomly-sdktookthis rewrite once and spent four review rounds undoing it. Verified here: this repo
has no field it would touch (
go fix -omitzero -diff ./...is empty), so the flag isbelt-and-braces rather than load-bearing — it stays on the command line so the next
run cannot regress.
Changes
slicescontainsplugin/analyzer.go(alias scan) andplugin/parse.go(appendUnique) — a linear-scan loop becomesslices.Containsslicesbackwardplugin/parse.go— the descending index loop oversrc.Tracebecomesfor _, t := range slices.Backward(src.Trace), preserving the sink→entry-point reversal the CallPath contract needsThree hunks, all behaviour-identical.
One non-analyzer edit: the
slicesbackwardrewrite left a stray blank line at the topof the loop body (
gofmtdoes not remove it). That blank line is deleted. It iswhitespace only.
Rejected
Nothing beyond the two analyzers excluded above. Every remaining hunk was read
individually and is a mechanical rewrite with no behaviour change.
No generated file, testdata fixture, golden or frozen fixture is touched — every hunk
is in hand-written
plugin/*.go.Checks
go build ./...,go test ./...,go vet ./...,gofmt -l .(empty) andgo mod tidy -diffall pass locally. TheFuzzParseGovulncheckJSONtarget was also run for10s against the rewritten parser and passes.
🤖 Generated with Claude Code