Help us shape the future of Go! Take the 2026 Go Developer Survey

testleak

package
v1.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package testleak centralises goroutine-leak detection for tests. It wraps goleak.VerifyTestMain with a shared ignore list for the long-lived goroutines gopherstack legitimately runs (metrics collectors, persistence timers, runtime/test-framework internals) so individual packages can opt in with a one-line TestMain:

func TestMain(m *testing.M) { testleak.VerifyTestMain(m) }

Packages that spawn their own known-persistent goroutines can pass extra goleak.Option values (e.g. goleak.IgnoreTopFunction("...")).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Baseline

func Baseline(t *testing.T, marker string) []goleak.Option

Baseline waits for a goroutine stack containing marker, then ignores every live goroutine. Not for parallel tests: it inspects the whole process.

func DefaultIgnores

func DefaultIgnores() []goleak.Option

DefaultIgnores exposes the shared ignore list for callers that verify goroutines directly (e.g. goleak.VerifyNone) instead of via TestMain.

func VerifyTestMain

func VerifyTestMain(m *testing.M, extra ...goleak.Option)

VerifyTestMain runs the package's tests via m and then asserts that no unexpected goroutines were leaked, exiting non-zero if any are found. Pass extra options to ignore package-specific long-lived goroutines.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL