Skip to content

x/website: out of date docs in effective go #68808

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
ifross89 opened this issue Aug 9, 2024 · 2 comments
Closed

x/website: out of date docs in effective go #68808

ifross89 opened this issue Aug 9, 2024 · 2 comments
Assignees
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

@ifross89
Copy link

ifross89 commented Aug 9, 2024

Hi, effective go still references having to do e.g.

req := req in a for loop:

The bug is that in a Go for loop, the loop variable is reused for each iteration, so the req variable is shared across all goroutines. That's not what we want. We need to make sure that req is unique for each goroutine. Here's one way to do that, passing the value of req as an argument to the closure in the goroutine:

This is no longer correct as of 1.21 (https://go.dev/blog/loopvar-preview)

What is the URL of the page with the issue?

https://go.dev/doc/effective_go

What is your user agent?

Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:129.0) Gecko/20100101 Firefox/129.0

Screenshot

image

What did you do?

Visit the page

What did you expect to see?

Up-to-date docs explaining how since go1.22 you don't need to do the loopvar trick.

What did you see instead?

Docs explaining that you need to do req := req in a for loop.

@gopherbot gopherbot added this to the Unreleased milestone Aug 9, 2024
@gopherbot gopherbot added the Documentation Issues describing a change to documentation. label Aug 9, 2024
@robpike robpike self-assigned this Aug 9, 2024
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/604575 mentions this issue: _content/doc/effective_go: remove discussion of loop variable reuse

@dmitshur dmitshur added NeedsFix The path to resolution is known, but the work has not been done. FixPending Issues that have a fix which has not yet been reviewed or submitted. labels Aug 10, 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

5 participants