mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-12 03:33:33 +08:00
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:
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user