goroutines

package
v0.1.16 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2021 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Format

func Format(gs ...*Goroutine) []byte

Format formats Goroutines back into the normal string representation.

func NoLeaks

func NoLeaks(t ErrorReporter, wait time.Duration) func()

NoLeaks helps test that a test isn't leaving extra goroutines after it finishes.

The normal way to use it is:

func TestFoo(t *testing.T) {
  defer goroutines.NoLeaks(t, time.Second)()

  ... Normal test code here ...

}

The test will fail if there are goroutines running at the end of the test that weren't running at the beginning. Since testing for goroutines being finished can be racy, the detector can wait the specified duration for the set of goroutines to return to the initial set.

Types

type ErrorReporter

type ErrorReporter interface {
	Errorf(format string, args ...interface{})
}

ErrorReporter is used by NoLeaks to report errors. testing.T implements this interface and is normally passed.

type Frame

type Frame struct {
	Call   string
	File   string
	Line   int
	Offset int
}

Frame represents a single stack frame.

type Goroutine

type Goroutine struct {
	ID      int
	State   string
	Stack   []*Frame
	Creator *Frame
}

func Get

func Get() ([]*Goroutine, error)

Get gets a set of currently running goroutines and parses them into a structured representation.

func Parse

func Parse(buf []byte, ignore bool) ([]*Goroutine, error)

Parse parses a stack trace into a structure representation.

Jump to

Keyboard shortcuts

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