stacktrace

package module
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2025 License: MPL-2.0 Imports: 14 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

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   	   96330	     12771 ns/op	     688 B/op	       7 allocs/op
PASS

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

func Disable()

func Enable

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