Fix go 1.17 build: use atomic.LoadInt32/StoreInt32 instead of atomic.Int32#6
Merged
Conversation
atomic.Int32 (the typed wrapper with .Load()/.Store() methods) is a Go 1.19 addition, but go.mod declares go 1.17 and CI builds against 1.17 — the previous change broke the build with: ./hdate.go:187:42: undefined: atomic.Int32 Switch to the function-form atomics on a plain [N]int32 array; they generate the same instructions on x86/arm and have existed since Go 1.0, so the cache stays race-free with no runtime overhead change.
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.
Summary
PR #5 merged with the Go 1.19+ form of atomic (
atomic.Int32with.Load()/.Store()methods), butgo.moddeclaresgo 1.17and CI builds against Go 1.17. The currentmainbuild is failing with:This switches to the function-form atomics (
atomic.LoadInt32/atomic.StoreInt32) on a plain[N]int32array. These have existed since Go 1.0 and generate the same MOV instructions on x86/arm as the typed wrapper, so the cache stays race-free with no change to runtime behavior or performance.Test plan
go build -v ./...succeedsgo test ./...passesgo test -race ./...cleango vet ./...cleanstaticcheck -checks=all ./...cleanGenerated by Claude Code