Package leaktest provides tools to detect leaked goroutines in tests. To use it, call "defer leaktest.Check(t)()" at the beginning of each test that may use goroutines. copied out of the cockroachdb source tree with slight modifications to be more re-useable
TickerInterval defines the interval used by the ticker in Check* functions.
Check snapshots the currently-running goroutines and returns a function to be run at the end of tests to see whether any goroutines leaked, waiting up to 5 seconds in error conditions
CheckContext is the same as Check, but uses a context.Context for cancellation and timeout control
CheckTimeout is the same as Check, but with a configurable timeout
ErrorReporter is a tiny subset of a testing.TB to make testing not such a massive pain