Closed bwplotka closed 1 year ago
Found workaround:
func BenchmarkGoroutines(b *testing.B) {
defer goleak.VerifyNone(
b,
goleak.IgnoreTopFunction("testing.(*B).run1"),
goleak.IgnoreTopFunction("testing.(*B).doBench"),
)
b.ResetTimer()
for i := 0; i < b.N; i++ {
wg := sync.WaitGroup{}
wg.Add(2)
go func() {
defer wg.Done()
}()
go func() {
defer wg.Done()
}()
wg.Wait()
}
}
It would be amazing to have goleak working on Benchmarks as well. However, I think some functions might needed to be filtered by default. Repro:
Output:
Tested on both Go version 1.18.3 and 1.19