MCPcopy Index your code
hub / github.com/pkg/errors / Format

Method Format

stack.go:64–84  ·  view source on GitHub ↗

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 GOP

(s fmt.State, verb rune)

Source from the content-addressed store, hash-verified

62// GOPATH separated by \n\t (<funcname>\n\t<path>)
63// %+v equivalent to %+s:%d
64func (f Frame) Format(s fmt.State, verb rune) {
65 switch verb {
66 case 's':
67 switch {
68 case s.Flag('+'):
69 io.WriteString(s, f.name())
70 io.WriteString(s, "\n\t")
71 io.WriteString(s, f.file())
72 default:
73 io.WriteString(s, path.Base(f.file()))
74 }
75 case 'd':
76 io.WriteString(s, strconv.Itoa(f.line()))
77 case 'n':
78 io.WriteString(s, funcname(f.name()))
79 case 'v':
80 f.Format(s, 's')
81 io.WriteString(s, ":")
82 f.Format(s, 'd')
83 }
84}
85
86// MarshalText formats a stacktrace Frame as a text string. The output is the
87// same as that of fmt.Sprintf("%+v", f), but without newlines or tabs.

Callers 2

FormatMethod · 0.45
formatSliceMethod · 0.45

Calls 4

nameMethod · 0.95
fileMethod · 0.95
lineMethod · 0.95
funcnameFunction · 0.85

Tested by

no test coverage detected