stack

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Colorize      bool
	FilterRuntime bool   // hide runtime.* frames, default true
	MaxFrames     int    // 0 = unlimited
	RelativeTo    string // base path to make file paths relative
}

Config controls formatting behavior.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a Config with sensible defaults.

type Frame

type Frame struct {
	Function  string // fully qualified function name
	ShortFunc string // just the function name
	Package   string // package path
	File      string // absolute file path
	ShortFile string // filename only
	Line      int
}

Frame represents a single stack frame.

func Caller

func Caller(skip int) Frame

Caller returns a single Frame for the immediate caller. skip=0 means the caller of Caller.

type Trace

type Trace struct {
	Frames []Frame
}

Trace represents an ordered list of stack frames.

func Capture

func Capture(skip int) Trace

Capture returns the current stack trace. skip=0 means the caller of Capture.

func (Trace) Format

func (t Trace) Format(cfg Config) string

Format renders the trace as a readable string.

Jump to

Keyboard shortcuts

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