houqp / goleak

Goroutine leak detector

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

goleak GoDoc Build Status Coverage Status

Goroutine leak detector to help avoid Goroutine leaks.

Development Status: Alpha

goleak is still in development, and APIs are still in flux.

Installation

You can use go get to get the latest version:

go get -u go.uber.org/goleak

goleak also supports semver releases. It is compatible with Go 1.5+.

Quick Start

To verify that there are no unexpected goroutines running at the end of a test:

func TestA(t *testing.T) {
	defer goleak.Verify(t)

	// test logic here.
}

Instead of checking for leaks at the end of every test, goleak can also be run at the end of every test package by creating a TestMain function for your package:

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

About

Goroutine leak detector

License:MIT License


Languages

Language:Go 96.0%Language:Makefile 3.1%Language:Shell 0.9%