Documentation
¶
Overview ¶
package caller implements easy use of metadata for caller functions.
forked from "github.com/pkg/errors"
Index ¶
- func Error(err error, msg string) error
- func Errorf(err error, format string, args ...any) error
- func Name() string
- func NameSkip(skip int) string
- func Nm() string
- func NmSkip(skip int) string
- func Path() string
- func PathSkip(skip int) string
- func ShortPathSkip(skip int) string
- type Frame
- type StackTrace
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Name ¶
func Name() string
Name return caller function name and line number information
based on runtime.Caller
func NameSkip ¶
NameSkip is similar to Name but with skip specified
note: NameSkip(1) is equivalent to runtime.Caller(0)
func Nm ¶
func Nm() string
Nm return caller function abbr and line number information
based on runtime.Caller
func NmSkip ¶
NmSkip is similar to Nm but with skip specified
note: NmSkip(1) is equivalent to runtime.Caller(0)
func Path ¶
func Path() string
Path return caller file name and line number information
note: Path(1) is equivalent to runtime.Caller(0)
func PathSkip ¶
PathSkip is similar to Path but with skip specified
note: PathSkip(1) is equivalent to runtime.Caller(0)
func ShortPathSkip ¶ added in v0.5.0
ShortPathSkip is similar to PathSkip but in short string form
note: ShortPathSkip(1) is equivalent to runtime.Caller(0)
Types ¶
type Frame ¶ added in v0.8.1
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 ¶ added in v0.8.1
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 ¶ added in v0.8.1
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 StackTrace ¶ added in v0.8.1
type StackTrace []Frame
StackTrace is stack of Frames from innermost (newest) to outermost (oldest).
func (StackTrace) Format ¶ added in v0.8.1
func (st StackTrace) Format(s fmt.State, verb rune)
Format formats the stack of Frames according to the fmt.Formatter interface.
%s lists source files for each Frame in the stack %v lists the source file and line number for each Frame in the stack
Format accepts flags that alter the printing of some verbs, as follows:
%+v Prints filename, function, and line number for each Frame in the stack.