Skip to content

Commit ac4e2bb

Browse files
mpywclaude
andcommitted
fix: Add Go 1.25+ build tag for WaitGroup.Go spawnerlabel tests
Split sync.WaitGroup.Go tests into separate file with go1.25 build tag to maintain compatibility with both Go 1.24 and 1.25. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 6f46bae commit ac4e2bb

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//go:build go1.25
2+
3+
package spawnerlabel
4+
5+
import (
6+
"fmt"
7+
"sync"
8+
)
9+
10+
// [BAD]: Missing label - calls sync.WaitGroup.Go with func arg
11+
func missingLabelWaitgroup() { // want `function "missingLabelWaitgroup" should have //goroutinectx:spawner directive \(calls sync\.WaitGroup\.Go with func argument\)`
12+
var wg sync.WaitGroup
13+
wg.Go(func() {
14+
fmt.Println("work")
15+
})
16+
wg.Wait()
17+
}
18+
19+
// [GOOD]: Traditional WaitGroup pattern (Add/Done) - not spawn method
20+
func goodTraditionalWaitgroup() {
21+
var wg sync.WaitGroup
22+
wg.Add(1)
23+
go func() {
24+
defer wg.Done()
25+
fmt.Println("work")
26+
}()
27+
wg.Wait()
28+
}
29+
30+
// [BAD]: Multiple spawn types including WaitGroup.Go
31+
func multipleSpawnTypesWithWaitgroup() { // want `function "multipleSpawnTypesWithWaitgroup" should have //goroutinectx:spawner directive \(calls sync\.WaitGroup\.Go with func argument\)`
32+
var wg sync.WaitGroup
33+
wg.Go(func() {
34+
fmt.Println("work")
35+
})
36+
wg.Wait()
37+
}

0 commit comments

Comments
 (0)