build: modernize with "go fix -waitgroupgo": use WaitGroup.Go
This commit is contained in:
+12
-24
@@ -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{})
|
||||
|
||||
Reference in New Issue
Block a user