Goroutine leak detector to help avoid Goroutine leaks.
Development Status: Alpha
goleak is still in development, and APIs are still in flux.
Installation
You can use go get
to get the latest version:
go get -u go.uber.org/goleak
goleak
also supports semver releases. It is compatible with Go 1.5+.
Quick Start
To verify that there are no unexpected goroutines running at the end of a test:
func TestA(t *testing.T) {
defer goleak.Verify(t)
// test logic here.
}
Instead of checking for leaks at the end of every test, goleak
can also be run
at the end of every test package by creating a TestMain
function for your
package:
func TestMain(m *testing.M) {
goleak.VerifyTestMain(m)
}