diff --git a/cmd/main.go b/cmd/main.go index 9548751a..bd8ecf97 100755 --- a/cmd/main.go +++ b/cmd/main.go @@ -23,9 +23,7 @@ import ( func parallel(fns ...func()) { var wg sync.WaitGroup for _, fn := range fns { - wg.Go(func() { - fn() - }) + wg.Go(fn) } wg.Wait() } diff --git a/internal/logging/accesslog/file_logger_test.go b/internal/logging/accesslog/file_logger_test.go index 66672273..01795970 100644 --- a/internal/logging/accesslog/file_logger_test.go +++ b/internal/logging/accesslog/file_logger_test.go @@ -82,12 +82,10 @@ func TestConcurrentAccessLoggerLogAndFlush(t *testing.T) { func parallelLog(logger *AccessLogger, req *http.Request, resp *http.Response, n int) { var wg sync.WaitGroup - wg.Add(n) for range n { - go func() { - defer wg.Done() + wg.Go(func() { logger.Log(req, resp) - }() + }) } wg.Wait() } diff --git a/internal/task/task_test.go b/internal/task/task_test.go index fb9720c2..76faa84f 100644 --- a/internal/task/task_test.go +++ b/internal/task/task_test.go @@ -128,7 +128,6 @@ func TestFinishMultipleCalls(t *testing.T) { task := testTask() var wg sync.WaitGroup n := 20 - wg.Add(n) for range n { wg.Go(func() { task.Finish(nil) diff --git a/internal/utils/io.go b/internal/utils/io.go index 5427a9f9..f204fa73 100644 --- a/internal/utils/io.go +++ b/internal/utils/io.go @@ -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) diff --git a/internal/utils/ref_count_test.go b/internal/utils/ref_count_test.go index 628b8f36..17bb197b 100644 --- a/internal/utils/ref_count_test.go +++ b/internal/utils/ref_count_test.go @@ -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()