# README
goleak

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)
}
# Functions
FindLeaks looks for extra goroutines, and returns a descriptive error if any are found.
IgnoreTopFunction ignores any goroutines where the specified function is at the top of the stack.
VerifyNoLeaks calls FindLeaks and calls Error on the passed in TestingT if any leaks are found.
VerifyTestMain can be used in a TestMain function for package tests to verify that there were no goroutine leaks.