refactor: use WaitGroup.Go to simplify code (#16539)

### Summary

Adopt sync.WaitGroup.Go (Go 1.25) to simplify tracked goroutine
spawning. This replaces the error-prone trio of wg.Add(1), go func(),
and defer wg.Done() with a single, self-contained call.

More info: https://github.com/golang/go/issues/63796

Signed-off-by: grandpig <grandpig@outlook.com>
This commit is contained in:
grandpig
2026-07-02 13:41:53 +08:00
committed by GitHub
parent d0d0339428
commit 17e3e34e78
22 changed files with 69 additions and 138 deletions

View File

@@ -565,16 +565,14 @@ func TestParser_ConcurrentSafety(t *testing.T) {
var wg sync.WaitGroup
n := 8
for range n {
wg.Add(1)
go func() {
defer wg.Done()
wg.Go(func() {
for range 5 {
eng := &MockEngine{NumPages: 2}
if _, err := p.ParseRaw(context.Background(), eng, mockDLA); err != nil {
t.Errorf("ParseRaw: %v", err)
}
}
}()
})
}
wg.Wait()
}