trace

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CurrentBinary

func CurrentBinary() string

CurrentBinary gives the name of the executable running the current Go code

func GetSourceCodeRef

func GetSourceCodeRef(skip int, config StackConfig) string

GetSourceCodeRef returns the callers source code reference

func GetStackTrace

func GetStackTrace(skip int, config StackConfig) []string

GetStackTrace returns a rendered stacktrace of the calling code, skipping `skip` frames in the stack prior to this function

func GetStackTraceLegacy

func GetStackTraceLegacy(skip int) []string

GetStackTraceLegacy returns a rendered stacktrace of the calling code, skipping `skip` frames in the stack (1 is the GetStackTrace frame itself). Deprecated: use GetStackTrace

func PackagePath

func PackagePath(a any) string

PackagePath returns the package path for a type this will panic for any nil-like object Typically you would use this with a struct, such as testing.T or http.Server

func StripTestStacks

func StripTestStacks(_ *testing.T, b []byte) []byte

StripTestStacks strips "testing/testing.go:XXX" and "runtime/asm_XXXX.s:XXX" from stacktraces to avoid flappers on go version changes. Deprecated: use StackConfig.TrimRuntime

Types

type Merge

type Merge struct {
	// contains filtered or unexported fields
}

func (*Merge) Add

func (m *Merge) Add(trace []string, binary string)

func (*Merge) FullTrace

func (m *Merge) FullTrace() []string

type StackConfig

type StackConfig struct {
	// RemoveLambdas will remove anonymous functions from the call stack
	RemoveLambdas bool
	// PackagesShown, if not empty, will limit the call stack to functions from these packages
	PackagesShown []string
	// TrimRuntime will remove entries from the Go runtime
	TrimRuntime bool
	// FormatStack is the format for lines in the stack trace
	// The default will print the source reference and the function name
	FormatStack func(stack.Call) string
	// FormatReference is the formatter used when creating source code references
	FormatReference func(stack.Call) string
}

Jump to

Keyboard shortcuts

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