{"modulePath":"github.com/go-stack/stack","version":"v1.8.1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package stack\n\nPackage stack implements utilities to capture, manipulate, and format call stacks. It provides a simpler API than package runtime.\n\nThe implementation takes care of the minutia and special cases of interpreting the program counter (pc) values returned by runtime.Callers.\n\nPackage stack's types implement fmt.Formatter, which provides a simple and flexible way to declaratively configure formatting when used with logging or error tracking packages.\n\n## Variables\n\n```go\nvar ErrNoFunc = errors.New(\"no call stack information\")\n```\nErrNoFunc means that the Call has a nil \\*runtime.Func. The most likely cause is a Call with the zero value.\n\n## Types\n\n```go\ntype Call struct {\n\t// contains filtered or unexported fields\n}\n```\nCall records a single function invocation from a goroutine stack.\n\n```go\nfunc Caller(skip int) Call\n```\nCaller returns a Call from the stack of the current goroutine. The argument skip is the number of stack frames to ascend, with 0 identifying the calling function.\n\n```go\nfunc (c Call) Format(s fmt.State, verb rune)\n```\nFormat implements fmt.Formatter with support for the following verbs.\n\n\t%s    source file\n\t%d    line number\n\t%n    function name\n\t%k    last segment of the package path\n\t%v    equivalent to %s:%d\n\nIt accepts the '+' and '#' flags for most of the verbs as follows.\n\n\t%+s   path of source file relative to the compile time GOPATH,\n\t      or the module path joined to the path of source file relative\n\t      to module root\n\t%#s   full path of source file\n\t%+n   import path qualified function name\n\t%+k   full package path\n\t%+v   equivalent to %+s:%d\n\t%#v   equivalent to %#s:%d\n\n```go\nfunc (c Call) Frame() runtime.Frame\n```\nFrame returns the call frame infomation for the Call.\n\n```go\nfunc (c Call) MarshalText() ([]byte, error)\n```\nMarshalText implements encoding.TextMarshaler. It formats the Call the same as fmt.Sprintf(\"%v\", c).\n\n```go\nfunc (c Call) PC() uintptr\n```\nPC returns the program counter for this call frame; multiple frames may have the same PC value.\n\nDeprecated: Use Call.Frame instead.\n\n```go\nfunc (c Call) String() string\n```\nString implements fmt.Stinger. It is equivalent to fmt.Sprintf(\"%v\", c).\n\n```go\ntype CallStack []Call\n```\nCallStack records a sequence of function invocations from a goroutine stack.\n\n```go\nfunc Trace() CallStack\n```\nTrace returns a CallStack for the current goroutine with element 0 identifying the calling function.\n\n```go\nfunc (cs CallStack) Format(s fmt.State, verb rune)\n```\nFormat implements fmt.Formatter by printing the CallStack as square brackets (\\[, ]) surrounding a space separated list of Calls each formatted with the supplied verb and options.\n\n```go\nfunc (cs CallStack) MarshalText() ([]byte, error)\n```\nMarshalText implements encoding.TextMarshaler. It formats the CallStack the same as fmt.Sprintf(\"%v\", cs).\n\n```go\nfunc (cs CallStack) String() string\n```\nString implements fmt.Stinger. It is equivalent to fmt.Sprintf(\"%v\", cs).\n\n```go\nfunc (cs CallStack) TrimAbove(c Call) CallStack\n```\nTrimAbove returns a slice of the CallStack with all entries above c removed.\n\n```go\nfunc (cs CallStack) TrimBelow(c Call) CallStack\n```\nTrimBelow returns a slice of the CallStack with all entries below c removed.\n\n```go\nfunc (cs CallStack) TrimRuntime() CallStack\n```\nTrimRuntime returns a slice of the CallStack with the topmost entries from the go runtime removed. It considers any calls originating from unknown files, files under GOROOT, or \\_testmain.go as part of the runtime.\n\n","path":"github.com/go-stack/stack","name":"stack","synopsis":"Package stack implements utilities to capture, manipulate, and format call stacks.","isRedistributable":true}
