Skip to content

x/website: first example of race_detector doc does not work for newest versions #69261

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dvordrova opened this issue Sep 4, 2024 · 2 comments
Labels
Documentation Issues describing a change to documentation. FixPending Issues that have a fix which has not yet been reviewed or submitted. NeedsFix The path to resolution is known, but the work has not been done. website
Milestone

Comments

@dvordrova
Copy link

dvordrova commented Sep 4, 2024

https://go.dev/doc/articles/race_detector

So this example with loop variable

func main() {
	var wg sync.WaitGroup
	wg.Add(5)
	for i := 0; i < 5; i++ {
		go func() {
			fmt.Println(i) // Not the 'i' you are looking for.
			wg.Done()
		}()
	}
	wg.Wait()
}

Should it have note with a link on loopvar-preview page?

Or should it be added new example like

func main() {
	var wg sync.WaitGroup
	wg.Add(5)
	var i int
	for i = 0; i < 5; i++ {
		go func() {
			fmt.Println(i) // Not the 'i' you are looking for.
			wg.Done()
		}()
	}
	wg.Wait()
}
@gopherbot gopherbot added this to the Unreleased milestone Sep 4, 2024
@dmitshur dmitshur added Documentation Issues describing a change to documentation. NeedsFix The path to resolution is known, but the work has not been done. labels Sep 4, 2024
@dmitshur
Copy link
Contributor

dmitshur commented Sep 4, 2024

Thanks for reporting.

CC @dvyukov, @ianlancetaylor.

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/610975 mentions this issue: doc/articles/race_detector: update for Go 1.22 loop variable changes

@dmitshur dmitshur added the FixPending Issues that have a fix which has not yet been reviewed or submitted. label Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Issues describing a change to documentation. FixPending Issues that have a fix which has not yet been reviewed or submitted. NeedsFix The path to resolution is known, but the work has not been done. website
Projects
None yet
Development

No branches or pull requests

3 participants