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

Golang x/website: out of date docs in effective go

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.

Comment From: gabyhelp

Related Issues and Documentation

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

Comment From: gopherbot

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