go.bigb.es/auxilia

v0.2.0
Doc Versions Source

Documentation

Package stacktrace captures and formats Go call stacks.

Types

T type Frame

src
type Frame struct {
	Function string
	File     string
	Line     int
}

Frame holds a single stack frame.

m func (Frame) String

src
func (f Frame) String() string

String returns a compact representation of the frame: Function (File:Line).

T type Trace

src
type Trace []Frame

Trace is an ordered list of stack frames, outermost first.

f func Capture

src
func Capture(skip int) Trace

Capture returns the current call stack, skipping skip frames from the caller's perspective. skip=0 means the caller of Capture is the first frame.

m func (Trace) Format

src
func (t Trace) Format(s fmt.State, verb rune)

Format implements fmt.Formatter for Trace.

  • %v / %s — compact: one line per frame, e.g. "funcName (file.go:42)"
  • %+v — verbose: two lines per frame (function, then indented location)

Source Files