goleaktest

package
v1.15.1-beta.5 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: MPL-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package goleaktest provides a small helper for wiring go.uber.org/goleak into a package's TestMain so goroutine leaks fail the test suite.

Usage in a package's <pkg>_test.go:

func TestMain(m *testing.M) {
    goleaktest.TestMain(m)
}

Tests that intentionally leave a goroutine running should clean it up. If that is impossible, register an ignore via goleak.IgnoreAnyFunction(...) and pass it through Options.Extra.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(m *testing.M, opts Options)

Run wires goleak verification around the package's test suite. It runs the tests and, if they pass, asserts no goroutines leaked.

func TestMain

func TestMain(m *testing.M)

Types

type Options

type Options struct {
	// IgnoreCurrent ignores all goroutines that are running at the time of the call.
	IgnoreCurrent bool
	// Extra appends additional goleak.Option values.
	Extra []goleak.Option
}

Options holds goleak options for packages that need to ignore known, long-lived goroutines.

Jump to

Keyboard shortcuts

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