diff options
| author | Ariel Otilibili <otilibil@eurecom.fr> | 2026-02-24 01:22:37 +0000 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2026-03-02 05:20:41 -0800 |
| commit | a6a4a41e225096a2599762d95af9c32d944a15e2 (patch) | |
| tree | fe86c044114c64c203f42d5b7357cb70e575f808 /src/cmd/api | |
| parent | 5c595a811eec69761f288b0affeeacdcaf1e5e86 (diff) | |
| download | go-a6a4a41e225096a2599762d95af9c32d944a15e2.tar.xz | |
all: test: remove unneeded loop variables
This CL follows from the abandoned CL 722961.
Alan Donovan asked if modernize would catch these changes; it does in part.
Here is how modernize was used:
1. Build the Go compiler from latest master
2. Clone x/tools and build modernize with the newest compiler
3. Then, do:
PATH=PATH_TO_BIN:$PATH go list ./... | xargs env PATH=PATH_TO_BIN:$PATH GOMOD=off MODERNIZE -forvar -fix -test -debug fpstv
4. For assurance, move into a package directory (i.e, cmd), and redo Step 3.
From the obtained result, it seems modernize did not remove the loop variable when:
- the range notation was not used
- the loop variable was not directly under the for directive.
Which does happens here:
# git ls-files | xargs -I {} perl -nE 'print "$ARGV:$.:$_" if /\s+(\w+) := \1$/' {} | grep _test
[...]
cmd/compile/internal/types2/api_test.go:2423: i := i
md/go/internal/modload/query_test.go:182: tt := tt
md/go/internal/web/url_test.go:17: tc := tc
cmd/go/internal/web/url_test.go:49: tc := tc
cmd/internal/par/queue_test.go:54: i := i
runtime/syscall_windows_test.go:781: arglen := arglen
Link: https://go-review.googlesource.com/c/go/+/722961/comments/e8d47866_fc399fa1
Co-authored-by: Plamerdi Makela <plamerdi447@gmail.com>
Fixes #76411
Change-Id: I0c191cdca70dbea6efaf6796dca9c60e2afcd9ea
GitHub-Last-Rev: 77c3e11fc21a4ede70b733b567a1690edb944dc1
GitHub-Pull-Request: golang/go#77694
Reviewed-on: https://go-review.googlesource.com/c/go/+/746502
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Diffstat (limited to 'src/cmd/api')
| -rw-r--r-- | src/cmd/api/api_test.go | 1 | ||||
| -rw-r--r-- | src/cmd/api/main_test.go | 1 |
2 files changed, 0 insertions, 2 deletions
diff --git a/src/cmd/api/api_test.go b/src/cmd/api/api_test.go index 98ebf168ef..784bdb74e4 100644 --- a/src/cmd/api/api_test.go +++ b/src/cmd/api/api_test.go @@ -232,7 +232,6 @@ var warmupCache = sync.OnceFunc(func() { // Warm up the import cache in parallel. var wg sync.WaitGroup for _, context := range contexts { - context := context wg.Add(1) go func() { defer wg.Done() diff --git a/src/cmd/api/main_test.go b/src/cmd/api/main_test.go index ed366be4e7..7917423eac 100644 --- a/src/cmd/api/main_test.go +++ b/src/cmd/api/main_test.go @@ -121,7 +121,6 @@ func Check(t *testing.T) { walkers := make([]*Walker, len(contexts)) var wg sync.WaitGroup for i, context := range contexts { - i, context := i, context wg.Add(1) go func() { defer wg.Done() |
