Skip to content

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

@ifross89

Description

@ifross89

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.

Metadata

Metadata

Assignees

Labels

DocumentationIssues describing a change to documentation.FixPendingIssues that have a fix which has not yet been reviewed or submitted.FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.website

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions