Format of frame 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 co
(s fmt.State, verb rune)
| 119 | // GOPATH separated by \n\t (<funcname>\n\t<path>) |
| 120 | // %+v equivalent to %+s:%d |
| 121 | func (f frame) Format(s fmt.State, verb rune) { |
| 122 | switch verb { |
| 123 | case 's': |
| 124 | switch { |
| 125 | case s.Flag('+'): |
| 126 | _, _ = io.WriteString(s, f.name()) |
| 127 | _, _ = io.WriteString(s, "\n\t") |
| 128 | _, _ = io.WriteString(s, f.file()) |
| 129 | default: |
| 130 | _, _ = io.WriteString(s, path.Base(f.file())) |
| 131 | } |
| 132 | case 'd': |
| 133 | _, _ = io.WriteString(s, strconv.Itoa(f.line())) |
| 134 | case 'n': |
| 135 | _, _ = io.WriteString(s, funcname(f.name())) |
| 136 | case 'v': |
| 137 | f.Format(s, 's') |
| 138 | _, _ = io.WriteString(s, ":") |
| 139 | f.Format(s, 'd') |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | // MarshalText formats a stacktrace Frame as a text string. The output is the |
| 144 | // same as that of fmt.Sprintf("%+v", f), but without newlines or tabs. |