stacktrace

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: Apache-2.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package stacktrace provides support for gathering stack traces efficiently.

Simplified version of uber-go/zap implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Take

func Take(skip int) string

Take returns a string representation of the current stacktrace.

skip is the number of frames to skip before recording the stack trace. skip=0 identifies the caller of Take.

Types

type Depth

type Depth int

Depth specifies how deep of a stack trace should be captured.

const (
	// First captures only the first frame.
	First Depth = iota

	// Full captures the entire call stack, allocating more
	// storage for it if needed.
	Full
)

type Formatter

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

Formatter formats a stack trace into a readable string representation.

func NewFormatter

func NewFormatter(b *bytes.Buffer) Formatter

NewFormatter builds a new Formatter.

func (*Formatter) FormatFrame

func (sf *Formatter) FormatFrame(frame runtime.Frame)

FormatFrame formats the given frame.

func (*Formatter) FormatStack

func (sf *Formatter) FormatStack(stack *Stack)

FormatStack formats all remaining frames in the provided stacktrace -- minus the final runtime.main/runtime.goexit frame.

type Stack

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

Stack is a captured stack trace.

func (*Stack) Count

func (st *Stack) Count() int

Count reports the total number of frames in this stacktrace. Count DOES NOT change as Next is called.

func (*Stack) Free

func (st *Stack) Free()

Free releases resources associated with this stacktrace and returns it back to the pool.

func (*Stack) Next

func (st *Stack) Next() (runtime.Frame, bool)

Next returns the next frame in the stack trace, and a boolean indicating whether there are more after it.

Jump to

Keyboard shortcuts

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