Skip to content

docs: synchronize EventuallyWithT example state - #1999

Open
Skytuhua wants to merge 1 commit into
stretchr:masterfrom
Skytuhua:docs/synchronize-eventually-example
Open

Skytuhua wants to merge 1 commit into
stretchr:masterfrom
Skytuhua:docs/synchronize-eventually-example

Conversation

@Skytuhua

Copy link
Copy Markdown

Summary

Use atomic loads and stores for the state shared by the EventuallyWithT documentation example.

Changes

Replace the unsynchronized boolean with an int32 accessed through sync/atomic, which works with the minimum supported Go 1.17. Regenerate the forwarding and formatted assertion comments.

Motivation

Copying the original example into a test triggers the race detector. The updated example passes with -race on Go 1.17.13 and Go 1.27.3.

Validation: full go test -race ./... passes on both versions; go vet ./..., changed-file formatting, and two consecutive generation runs pass. The extracted example passes ten race-detector runs on Go 1.27.3.

Related issues

Related: #1919.

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.

1 participant