stack

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Frame

type Frame uintptr

Frame represents a program counter inside a stack frame. For historical reasons: if Frame is interpreted as a uintptr its value represents the program counter + 1.

func (Frame) Format

func (f Frame) Format(s fmt.State, verb rune)

Format formats the frame according to the fmt.Formatter interface.

%s    source file
%d    source line
%n    function name
%v    equivalent to %s:%d

Format accepts flags that alter the printing of some verbs, as follows:

%+s   function name and path of source file relative to the compile time
      GOPATH separated by \n\t (<funcname>\n\t<path>)
%+v   equivalent to %+s:%d

func (Frame) MarshalText

func (f Frame) MarshalText() ([]byte, error)

MarshalText formats a stacktrace Frame as a text string. The output is the same as that of fmt.Sprintf("%+v", f), but without newlines or tabs.

type Stack

type Stack []uintptr

stack represents a stack of program counters.

func Callers

func Callers(stackPosition int) *Stack

Callers Возвращает массив указателей из стека вызовов (переходов) PC - program counter

func (*Stack) StackTrace

func (s *Stack) StackTrace() Trace

type Trace

type Trace []Frame

Trace stack (массив) Frames от самых "поздних" к самым "ранним".

func (Trace) Format

func (st Trace) Format(s fmt.State, verb rune)

Format реализация интерфейса fmt.Formatter.

%s	список файлов для каждого фрейма в стеке
%v	список файлов с номерами строк, из которых был произведен вызов для каждого фрейма в стеке

Format принимает дополнительные флаги для некоторых "глаголов":

%+v печатает название файла, название функции и строку вызова для каждого фрейма в стеке

Jump to

Keyboard shortcuts

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