diff --git a/fs/log/slog_test.go b/fs/log/slog_test.go index 07d32be06..1c61a3868 100644 --- a/fs/log/slog_test.go +++ b/fs/log/slog_test.go @@ -288,22 +288,18 @@ func TestOutputHandlerConcurrency(t *testing.T) { // Goroutines calling Handle (text format) for range goroutines { - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { for range iterations { r := slog.NewRecord(t0, slog.LevelInfo, "concurrent text", 0) r.AddAttrs(slog.String("object", "obj")) _ = h.Handle(ctx, r) } - }() + }) } // Goroutines calling setFormat (switching between text and JSON) for range 2 { - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { for j := range iterations { if j%2 == 0 { h.setFormat(logFormatDate | logFormatTime) @@ -311,23 +307,19 @@ func TestOutputHandlerConcurrency(t *testing.T) { h.setFormat(logFormatJSON) } } - }() + }) } // Goroutines calling setFormatFlags / clearFormatFlags - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { for range iterations { h.setFormatFlags(logFormatPid | logFormatMicroseconds) h.clearFormatFlags(logFormatPid | logFormatMicroseconds) } - }() + }) // Goroutines calling SetLevel - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { for j := range iterations { if j%2 == 0 { h.SetLevel(slog.LevelDebug) @@ -335,28 +327,24 @@ func TestOutputHandlerConcurrency(t *testing.T) { h.SetLevel(slog.LevelInfo) } } - }() + }) // Goroutines calling SetOutput / ResetOutput - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { noop := func(_ slog.Level, _ string) {} for range iterations { h.SetOutput(noop) h.ResetOutput() } - }() + }) // Goroutines calling WithAttrs / WithGroup (reads format) - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { for range iterations { _ = h.WithAttrs(nil) _ = h.WithGroup("g") } - }() + }) // Use a channel with a timeout to detect deadlocks done := make(chan struct{}) diff --git a/vfs/nodeaux_test.go b/vfs/nodeaux_test.go index d0c74c92f..47d9d8148 100644 --- a/vfs/nodeaux_test.go +++ b/vfs/nodeaux_test.go @@ -58,16 +58,14 @@ func TestAuxConcurrent(t *testing.T) { wg sync.WaitGroup ) for i := range owners { - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { owner := &i for j := range iterations { value := fmt.Sprintf("%d-%d", i, j) a.SetAux(owner, value) assert.Equal(t, value, a.Aux(owner)) } - }() + }) } wg.Wait() }