purego: apply go fix modernizations - #504
Merged
hajimehoshi merged 1 commit intoAug 30, 2026
Merged
Conversation
Go 1.27's go fix rewrites constructs that newer standard library APIs express better. Running it over every GOOS/GOARCH this module builds for turns up three sites, all mechanical: compareStatus walks the lines of a /proc status file, so the slice from strings.Split only exists to be ranged over; SplitSeq yields the same lines without materializing it. The same function sorts a field list with sort.Slice and a less function that is plain string comparison, which is what slices.Sort does for an ordered element type. NewCallback asks whether an argument is assignable to CDecl, a type known at compile time, so reflect.TypeFor names it directly instead of building a value to take the type of. The cgo-enabled cross builds could not be analyzed on the machine this ran on, which has no cross C toolchain; darwin/amd64 and darwin/arm64 with cgo were covered and reported nothing. 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.
What issue is this addressing?
None; no issue filed.
What type of issue is this addressing?
Neither bug, feature, nor security: a maintenance/cleanup change.
What this PR does | solves
Go 1.27's
go fixrewrites constructs that newer standard library APIs express better. Running it over every GOOS/GOARCH this module builds for turns up three sites, all mechanical:compareStatuswalks the lines of a/procstatus file, so the slice fromstrings.Splitonly exists to be ranged over;SplitSeqyields the same lines without materializing it.sort.Sliceand a less function that is plain string comparison, which is whatslices.Sortdoes for an ordered element type.NewCallbackasks whether an argument is assignable toCDecl, a type known at compile time, soreflect.TypeFornames it directly instead of building a value to take the type of.go fixonly analyzes the files selected by the current build constraints, so it was run for each of darwin, linux, freebsd, netbsd, windows, android, ios and js across the architectures purego supports, with cgo both on and off, plus thefaketimetag. Only the two files here reported anything.The cgo-enabled cross builds could not be analyzed on the machine this ran on, which has no cross C toolchain; darwin/amd64 and darwin/arm64 with cgo were covered and reported nothing.
Verified with
gofmt -l -s(clean),go vetfor linux and windows,go buildfor windows, andgo test ./...on darwin/arm64.🤖 Generated with Claude Code