Back to godoc.org
go.uber.org/goleak

Package goleak

v1.1.10
Latest Go to latest

The latest major version is .

Published: Jul 21, 2020 | License: MIT | Module: go.uber.org/goleak

Overview

Package goleak is a Goroutine leak detector.

Index

func Find

func Find(options ...Option) error

Find looks for extra goroutines, and returns a descriptive error if any are found.

func VerifyNone

func VerifyNone(t TestingT, options ...Option)

VerifyNone marks the given TestingT as failed if any extra goroutines are found by Find. This is a helper method to make it easier to integrate in tests by doing:

defer VerifyNone(t)

func VerifyTestMain

func VerifyTestMain(m TestingM, options ...Option)

VerifyTestMain can be used in a TestMain function for package tests to verify that there were no goroutine leaks. To use it, your TestMain function should look like:

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

See https://golang.org/pkg/testing/#hdr-Main for more details.

This will run all tests as per normal, and if they were successful, look for any goroutine leaks and fail the tests if any leaks were found.

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option lets users specify custom verifications.

func IgnoreCurrent

func IgnoreCurrent() Option

IgnoreCurrent records all current goroutines when the option is created, and ignores them in any future Find/Verify calls.

func IgnoreTopFunction

func IgnoreTopFunction(f string) Option

IgnoreTopFunction ignores any goroutines where the specified function is at the top of the stack. The function name should be fully qualified, e.g., go.uber.org/goleak.IgnoreTopFunction

type TestingM

type TestingM interface {
	Run() int
}

TestingM is the minimal subset of testing.M that we use.

type TestingT

type TestingT interface {
	Error(...interface{})
}

TestingT is the minimal subset of testing.TB that we use.

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier