refactor(concurrency): replaced manual WaitGroup management with new wg.Go() and removed redundant code.

This commit is contained in:
yusing
2025-08-16 23:14:40 +08:00
parent 7a9b8b3fb9
commit 11af9d107a
8 changed files with 35 additions and 59 deletions

View File

@@ -92,16 +92,15 @@ func NewBidirectionalPipe(ctx context.Context, rw1 io.ReadWriteCloser, rw2 io.Re
func (p BidirectionalPipe) Start() error {
var wg sync.WaitGroup
wg.Add(2)
var srcErr, dstErr error
go func() {
wg.Go(func() {
srcErr = p.pSrcDst.Start()
wg.Done()
}()
go func() {
})
wg.Go(func() {
dstErr = p.pDstSrc.Start()
wg.Done()
}()
})
wg.Wait()
return errors.Join(srcErr, dstErr)
}