testleak

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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