stack

package
v2.0.0-...-b105bd3 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2015 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package stack implements utilities to capture, manipulate, and format call stacks.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Call

type Call uintptr

Call records a single function invocation from a goroutine stack. It is a wrapper for the program counter values returned by runtime.Caller and runtime.Callers and consumed by runtime.FuncForPC.

func (Call) Format

func (pc Call) Format(s fmt.State, c rune)

Format implements fmt.Formatter with support for the following verbs.

%s    source file
%d    line number
%n    function name
%v    equivalent to %s:%d

It accepts the '+' and '#' flags for most of the verbs as follows.

%+s   path of source file relative to the compile time GOPATH
%#s   full path of source file
%+n   import path qualified function name
%+v   equivalent to %+s:%d
%#v   equivalent to %#s:%d

type Trace

type Trace []Call

Trace records a sequence of function invocations from a goroutine stack.

func Callers

func Callers() Trace

Callers returns a Trace for the current goroutine with element 0 identifying the calling function.

func (Trace) Format

func (pcs Trace) Format(s fmt.State, c rune)

Format implements fmt.Formatter by printing the Trace as square brackes ([, ]) surrounding a space separated list of Calls each formatted with the supplied verb and options.

func (Trace) TrimAbove

func (pcs Trace) TrimAbove(pc Call) Trace

TrimAbove returns a slice of the Trace with all entries above pc removed.

func (Trace) TrimAboveName

func (pcs Trace) TrimAboveName(name string) Trace

TrimAboveName returns a slice of the Trace with all entries above the highest with function name name removed.

func (Trace) TrimBelow

func (pcs Trace) TrimBelow(pc Call) Trace

TrimBelow returns a slice of the Trace with all entries below pc removed.

func (Trace) TrimBelowName

func (pcs Trace) TrimBelowName(name string) Trace

TrimBelowName returns a slice of the Trace with all entries below the lowest with function name name removed.

func (Trace) TrimRuntime

func (pcs Trace) TrimRuntime() Trace

TrimRuntime returns a slice of the Trace with the topmost entries from the go runtime removed. It considers any calls originating from files under GOROOT as part of the runtime.

Notes

Bugs

Jump to

Keyboard shortcuts

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