Skip to content

Commit b04e595

Browse files
authored
doc: remove range capture in language guide (#3906)
Remove guidance on range capture in docs since Go 1.22+ fixes this issue. Used Gemini to search related contents and it seems this is the only place left.
1 parent 5caff80 commit b04e595

1 file changed

Lines changed: 0 additions & 5 deletions

File tree

doc/howwewritego.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -322,10 +322,6 @@ parallelize lightweight, millisecond-level tests.
322322
mutates the process as a whole e.g. by invoking `t.Chdir()`, or is dependent on
323323
execution order.
324324

325-
When using `t.Parallel()` in table-driven tests, you must capture the range
326-
variable to avoid race conditions. This ensures each subtest gets the correct
327-
data from its corresponding test case.
328-
329325
```go
330326
func TestTransform(t *testing.T) {
331327
for _, test := range []struct {
@@ -336,7 +332,6 @@ func TestTransform(t *testing.T) {
336332
{"uppercase", "hello", "HELLO"},
337333
{"empty", "", ""},
338334
} {
339-
test := test // capture range variable
340335
t.Run(test.name, func(t *testing.T) {
341336
t.Parallel() // Mark subtest for parallel execution.
342337
got := Transform(test.input)

0 commit comments

Comments
 (0)