stacktrace

package module
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2026 License: MPL-2.0 Imports: 12 Imported by: 0

README

stacktrace-go

An alternative to Go's native stack trace, that:

  • has colorized output
  • is fast
  • is thread-safe
  • shows go statement that created the panicking goroutine
  • shows the number of lines from the start of the function to the current line
  • allows to customize the printing of panic values
  • supports NO_COLOR environment variable

Tip: use -trimpath build flag to get shorter stack traces

Documentation: https://pkg.go.dev/github.com/antoniszymanski/stacktrace-go

Installation:

go get github.com/antoniszymanski/stacktrace-go

Example:

Example

Benchmark:

goos: linux
goarch: amd64
pkg: github.com/antoniszymanski/stacktrace-go
cpu: Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
BenchmarkHandle-8   	   63949	     19769 ns/op	     752 B/op	       7 allocs/op
PASS
ok  	github.com/antoniszymanski/stacktrace-go	1.460s

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CallStack added in v0.3.0

func CallStack(skip int, predicate func(frame runtime.Frame) bool) iter.Seq[runtime.Frame]

func Disable added in v0.2.0

func Disable()

func Enable added in v0.2.0

func Enable()

func Go

func Go(f func(), print func(w io.Writer, r any), predicate func(frame runtime.Frame) bool)

func Handle

func Handle(exit bool, print func(w io.Writer, r any), predicate func(frame runtime.Frame) bool)

func SplitFunctionPath added in v0.3.0

func SplitFunctionPath(functionPath string) (packagePath string, functionName string)

SplitFunctionPath splits the function path as formatted in runtime.Frame.Function, and returns the package path and function name components.

Types

This section is empty.

Jump to

Keyboard shortcuts

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