refactor(concurrency): simplify some waitgroup usage, remove extra wg.Done in wg.Go left in 11af9d1 in io.go

This commit is contained in:
yusing
2025-08-17 00:23:54 +08:00
parent b32750d545
commit 0862920324
5 changed files with 4 additions and 13 deletions

View File

@@ -95,11 +95,9 @@ func (p BidirectionalPipe) Start() error {
var srcErr, dstErr error
wg.Go(func() {
srcErr = p.pSrcDst.Start()
wg.Done()
})
wg.Go(func() {
dstErr = p.pDstSrc.Start()
wg.Done()
})
wg.Wait()
return errors.Join(srcErr, dstErr)

View File

@@ -15,9 +15,7 @@ func TestRefCounterAddSub(t *testing.T) {
rc.Add()
for range 2 {
wg.Go(func() {
rc.Sub()
})
wg.Go(rc.Sub)
}
wg.Wait()