神刀安全网

Leaktest – Goroutine leak detector

Leaktest

Refactored, tested variant of the goroutine leak detector found in the cockroachdb source tree.

Takes a snapshot of running goroutines at the start of a test, and at the end – compares the two and voila . Ignores runtime/sys goroutines. Doesn’t play nice with t.Parallel() right now, but there are plans to do so.

Example

This test fails, because it leaks a goroutine 😮

func TestPool(t *testing.T) {     defer leaktest.Check(t)()      go func() {         for {             time.Sleep(time.Second)         }     } }

LICENSE

Header in leaktest.go – Apache something, per the Go Authors

转载本站任何文章请注明:转载至神刀安全网,谢谢神刀安全网 » Leaktest – Goroutine leak detector

分享到:更多 ()

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址