Skip to content

purego: apply go fix modernizations - #504

Merged
hajimehoshi merged 1 commit into
ebitengine:mainfrom
hajimehoshi:claude/go-fix-modernization-f16e0c
Aug 30, 2026
Merged

purego: apply go fix modernizations#504
hajimehoshi merged 1 commit into
ebitengine:mainfrom
hajimehoshi:claude/go-fix-modernization-f16e0c

Conversation

@hajimehoshi

Copy link
Copy Markdown
Member

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 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.

go fix only 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 the faketime tag. 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 vet for linux and windows, go build for windows, and go test ./... on darwin/arm64.

🤖 Generated with Claude Code

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>
Copilot AI lite review requested due to automatic review settings August 30, 2026 08:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@TotallyGamerJet TotallyGamerJet left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hajimehoshi
hajimehoshi merged commit 63002e0 into ebitengine:main Aug 30, 2026
25 checks passed
@hajimehoshi
hajimehoshi deleted the claude/go-fix-modernization-f16e0c branch August 30, 2026 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants