Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/cmd/api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ 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()
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/api/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ 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()
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/cgo/internal/testerrors/errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func TestToleratesOptimizationFlag(t *testing.T) {
"",
"-O",
} {
cflags := cflags

t.Run(cflags, func(t *testing.T) {
testenv.MustHaveGoBuild(t)
testenv.MustHaveCGO(t)
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/cgo/internal/testsanitizers/asan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TestASAN(t *testing.T) {
{src: "arena_fail.go", memoryAccessError: "use-after-poison", errorLocation: "arena_fail.go:26", experiments: []string{"arenas"}},
}
for _, tc := range cases {
tc := tc

name := strings.TrimSuffix(tc.src, ".go")
t.Run(name, func(t *testing.T) {
t.Parallel()
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/cgo/internal/testsanitizers/cshared_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func TestShared(t *testing.T) {
}

for _, tc := range cases {
tc := tc

name := strings.TrimSuffix(tc.src, ".go")
//The memory sanitizer tests require support for the -msan option.
if tc.sanitizer == "memory" && !platform.MSanSupported(GOOS, GOARCH) {
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/cgo/internal/testsanitizers/libfuzzer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestLibFuzzer(t *testing.T) {
{goSrc: "libfuzzer2.go", cSrc: "libfuzzer2.c", expectedError: "panic: found it"},
}
for _, tc := range cases {
tc := tc

name := strings.TrimSuffix(tc.goSrc, ".go")
t.Run(name, func(t *testing.T) {
t.Parallel()
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/cgo/internal/testsanitizers/msan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func TestMSAN(t *testing.T) {
{src: "arena_fail.go", wantErr: true, experiments: []string{"arenas"}},
}
for _, tc := range cases {
tc := tc

name := strings.TrimSuffix(tc.src, ".go")
t.Run(name, func(t *testing.T) {
t.Parallel()
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/cgo/internal/testsanitizers/tsan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func TestTSAN(t *testing.T) {
{src: "tsan_tracebackctxt", needsRuntime: true}, // Subdirectory
}
for _, tc := range cases {
tc := tc

name := strings.TrimSuffix(tc.src, ".go")
t.Run(name, func(t *testing.T) {
t.Parallel()
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/cgo/internal/teststdio/stdio_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func TestTestRun(t *testing.T) {
"fib.go",
"hello.go",
} {
file := file

wantFile := strings.Replace(file, ".go", ".out", 1)
t.Run(file, func(t *testing.T) {
cmd := exec.Command(testenv.GoToolPath(t), "run", file)
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/compile/internal/gc/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func compileFunctions(profile *pgoir.Profile) {
compile = func(fns []*ir.Func) {
wg.Add(len(fns))
for _, fn := range fns {
fn := fn

queue(func(worker int) {
ssagen.Compile(fn, worker, profile)
compile(fn.Closures)
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/compile/internal/noder/noder.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func LoadPackage(filenames []string) {
// Move the entire syntax processing logic into a separate goroutine to avoid blocking on the "sem".
go func() {
for i, filename := range filenames {
filename := filename

p := noders[i]
sem <- struct{}{}
go func() {
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/compile/internal/ssa/_gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func main() {
genAllocators,
}
for _, a := range archs {
a := a // the funcs are ran concurrently at a later time
// the funcs are ran concurrently at a later time
tasks = append(tasks, func() {
genRules(a)
genSplitLoadRules(a)
Expand All @@ -184,7 +184,7 @@ func main() {
}
var wg sync.WaitGroup
for _, task := range tasks {
task := task

wg.Add(1)
go func() {
task()
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/compile/internal/test/reproduciblebuilds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestReproducibleBuilds(t *testing.T) {
}
t.Parallel()
for _, test := range tests {
test := test

t.Run(test, func(t *testing.T) {
t.Parallel()
var want []byte
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/compile/internal/test/ssa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func TestCode(t *testing.T) {

// Now we have a test binary. Run it with all the tests as subtests of this one.
for _, test := range tests {
test := test

if flag == ",softfloat" && !test.usesFloat {
// No point in running the soft float version if the test doesn't use floats.
continue
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/compile/internal/types2/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2599,7 +2599,7 @@ func fn() {
})

for _, test := range tests {
test := test

t.Run(test.name, func(t *testing.T) {
if got := len(idents[test.name]); got != 1 {
t.Fatalf("found %d identifiers named %s, want 1", got, test.name)
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/compile/internal/types2/sizes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func main() {
func TestGCSizes(t *testing.T) {
types2.DefPredeclaredTestFuncs()
for _, tc := range gcSizesTests {
tc := tc

t.Run(tc.name, func(t *testing.T) {
t.Parallel()
conf := types2.Config{Importer: defaultImporter(), Sizes: types2.SizesFor("gc", "amd64")}
Expand Down
1 change: 0 additions & 1 deletion src/cmd/compile/internal/types2/stdlib_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ func TestStdlib(t *testing.T) {
var wg sync.WaitGroup

for dir := range dirFiles {
dir := dir

cpulimit <- struct{}{}
wg.Add(1)
Expand Down
1 change: 0 additions & 1 deletion src/cmd/dist/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ func (t *tester) run() {
continue
}
anyIncluded = true
dt := dt // dt used in background after this iteration
if err := dt.fn(&dt); err != nil {
t.runPending(&dt) // in case that hasn't been done yet
t.failed = true
Expand Down
1 change: 0 additions & 1 deletion src/cmd/go/internal/modcmd/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ func runVerify(ctx context.Context, cmd *base.Command, args []string) {
sem <- token{}
errsc := make(chan []error, 1)
errsChans[i] = errsc
mod := mod // use a copy to avoid data races
go func() {
errsc <- verifyMod(moduleLoaderState, ctx, mod)
<-sem
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/go/internal/modfetch/coderepo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ func TestCodeRepoVersions(t *testing.T) {
testenv.MustHaveExternalNetwork(t)
fetcher := NewFetcher()
for _, tt := range codeRepoVersionsTests {
tt := tt

t.Run(strings.ReplaceAll(tt.path, "/", "_"), func(t *testing.T) {
if strings.Contains(tt.path, "gopkg.in") {
testenv.SkipFlaky(t, 54503)
Expand Down
10 changes: 5 additions & 5 deletions src/cmd/go/internal/modget/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ func (r *resolver) performLocalQueries(loaderstate *modload.State, ctx context.C
// build list.
func (r *resolver) performWildcardQueries(loaderstate *modload.State, ctx context.Context) {
for _, q := range r.wildcardQueries {
q := q

r.work.Add(func() {
if q.version == "none" {
r.queryNone(loaderstate, ctx, q)
Expand Down Expand Up @@ -1027,7 +1027,7 @@ func (r *resolver) checkWildcardVersions(loaderstate *modload.State, ctx context
// literals once.
func (r *resolver) performPathQueries(loaderstate *modload.State, ctx context.Context) {
for _, q := range r.pathQueries {
q := q

r.work.Add(func() {
if q.version == "none" {
r.queryNone(loaderstate, ctx, q)
Expand Down Expand Up @@ -1724,7 +1724,7 @@ func (r *resolver) checkPackageProblems(loaderstate *modload.State, ctx context.
}
sort.Slice(retractions, func(i, j int) bool { return retractions[i].m.Path < retractions[j].m.Path })
for i := range retractions {
i := i

r.work.Add(func() {
err := loaderstate.CheckRetractions(ctx, retractions[i].m)
if _, ok := errors.AsType[*modload.ModuleRetractedError](err); ok {
Expand All @@ -1745,7 +1745,7 @@ func (r *resolver) checkPackageProblems(loaderstate *modload.State, ctx context.
}
sort.Slice(deprecations, func(i, j int) bool { return deprecations[i].m.Path < deprecations[j].m.Path })
for i := range deprecations {
i := i

r.work.Add(func() {
deprecation, err := modload.CheckDeprecation(loaderstate, ctx, deprecations[i].m)
if err != nil || deprecation == "" {
Expand Down Expand Up @@ -1774,7 +1774,7 @@ func (r *resolver) checkPackageProblems(loaderstate *modload.State, ctx context.
// need previously. We can't handle that case without loading 'all'.
sumErrs := make([]error, len(r.buildList))
for i := range r.buildList {
i := i

m := r.buildList[i]
mActual := m
if mRepl := modload.Replacement(loaderstate, m); mRepl.Path != "" {
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/go/internal/modload/buildlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ func tidyPrunedRoots(loaderstate *State, ctx context.Context, mainModule module.
// that are only indirectly required. It is as unambiguous as possible.
continue
}
pkg := pkg

q.Add(func() {
skipModFile := true
_, _, _, _, err := importFromModules(loaderstate, ctx, pkg.path, tidy, nil, skipModFile)
Expand Down Expand Up @@ -1229,7 +1229,7 @@ func spotCheckRoots(loaderstate *State, ctx context.Context, rs *Requirements, m

work := par.NewQueue(runtime.GOMAXPROCS(0))
for m := range mods {
m := m

work.Add(func() {
if ctx.Err() != nil {
return
Expand Down
4 changes: 1 addition & 3 deletions src/cmd/go/internal/modload/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -1578,7 +1578,6 @@ func (ld *loader) resolveMissingImports(loaderstate *State, ctx context.Context)
continue
}

pkg := pkg
var mod module.Version
ld.work.Add(func() {
var err error
Expand Down Expand Up @@ -1762,7 +1761,7 @@ func (ld *loader) preloadRootModules(loaderstate *State, ctx context.Context, ro
needc := make(chan map[module.Version]bool, 1)
needc <- map[module.Version]bool{}
for _, path := range rootPkgs {
path := path

ld.work.Add(func() {
// First, try to identify the module containing the package using only roots.
//
Expand Down Expand Up @@ -2131,7 +2130,6 @@ func (ld *loader) checkTidyCompatibility(loaderstate *State, ctx context.Context
continue
}

pkg := pkg
ld.work.Add(func() {
mod, _, _, _, err := importFromModules(loaderstate, ctx, pkg.path, rs, mg, ld.skipImportModFiles)
if mod != pkg.mod {
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/go/internal/modload/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func TestQuery(t *testing.T) {
}
return nil
}
tt := tt

t.Run(strings.ReplaceAll(tt.path, "/", "_")+"/"+tt.query+"/"+tt.current+"/"+allow, func(t *testing.T) {
t.Parallel()

Expand Down
2 changes: 0 additions & 2 deletions src/cmd/go/internal/web/url_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ func TestURLToFilePath(t *testing.T) {
if tc.url == "" {
continue
}
tc := tc

t.Run(tc.url, func(t *testing.T) {
u, err := url.Parse(tc.url)
Expand Down Expand Up @@ -46,7 +45,6 @@ func TestURLFromFilePath(t *testing.T) {
if tc.filePath == "" {
continue
}
tc := tc

t.Run(tc.filePath, func(t *testing.T) {
u, err := urlFromFilePath(tc.filePath)
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/go/script_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func TestScript(t *testing.T) {
t.Fatal(err)
}
for _, file := range files {
file := file

name := strings.TrimSuffix(filepath.Base(file), ".txt")
t.Run(name, func(t *testing.T) {
t.Parallel()
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/internal/obj/ppc64/asm9.go
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,7 @@ func buildop(ctxt *obj.Link) {
// Configure the optab entries which may generate prefix opcodes.
prefixOptab := make([]Optab, 0, len(prefixableOptab))
for _, entry := range prefixableOptab {
entry := entry

if pfxEnabled && buildcfg.GOPPC64 >= entry.minGOPPC64 {
// Enable prefix opcode generation and resize.
entry.ispfx = true
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/internal/par/queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestQueueBacklog(t *testing.T) {
unblock := make(chan struct{})
for i := range started {
started[i] = make(chan struct{})
i := i

q.Add(func() {
close(started[i])
<-unblock
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/internal/script/scripttest/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ func RunTests(t *testing.T, ctx context.Context, engine *script.Engine, env []st
t.Fatal("no testdata")
}
for _, file := range files {
file := file

name := strings.TrimSuffix(filepath.Base(file), ".txt")
t.Run(name, func(t *testing.T) {
t.Parallel()
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/link/dwarf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func testDWARF(t *testing.T, buildmode string, expectDWARF bool, env ...string)
t.Parallel()

for _, prog := range []string{"testprog", "testprogcgo"} {
prog := prog

expectDWARF := expectDWARF
if runtime.GOOS == "aix" && prog == "testprogcgo" {
extld := os.Getenv("CC")
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/link/internal/ld/deadcode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestDeadcode(t *testing.T) {
[]string{"main.large"}},
}
for _, test := range tests {
test := test

t.Run(test.src, func(t *testing.T) {
t.Parallel()
src := filepath.Join("testdata", "deadcode", test.src+".go")
Expand Down
8 changes: 4 additions & 4 deletions src/cmd/link/internal/ld/dwarf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ func main() {}
},
}
for _, tc := range tests {
tc := tc

t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -473,7 +473,7 @@ func main() {
},
}
for _, tc := range tests {
tc := tc

t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -555,7 +555,7 @@ func main() {
},
}
for _, tc := range tests {
tc := tc

t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -1980,7 +1980,7 @@ func TestZeroSizedVariable(t *testing.T) {
// See go.dev/issues/54615.

for _, opt := range []string{NoOpt, DefaultOpt} {
opt := opt

t.Run(opt, func(t *testing.T) {
_, ex := gobuildAndExamine(t, zeroSizedVarProg, opt)

Expand Down
2 changes: 1 addition & 1 deletion src/cmd/link/internal/ld/ld_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ func main() {
},
}
for _, tt := range tests {
tt := tt

t.Run(tt.name, func(t *testing.T) {
t.Parallel()
tempDir := t.TempDir()
Expand Down
Loading