String returns the stackframe formatted in the same way as go does in runtime/debug.Stack()
()
| 51 | // String returns the stackframe formatted in the same way as go does |
| 52 | // in runtime/debug.Stack() |
| 53 | func (frame *StackFrame) String() string { |
| 54 | str := fmt.Sprintf("%s:%d (0x%x)\n", frame.File, frame.LineNumber, frame.ProgramCounter) |
| 55 | |
| 56 | source, err := frame.sourceLine() |
| 57 | if err != nil { |
| 58 | return str |
| 59 | } |
| 60 | |
| 61 | return str + fmt.Sprintf("\t%s: %s\n", frame.Name, source) |
| 62 | } |
| 63 | |
| 64 | // SourceLine gets the line of code (from File and Line) of the original source if possible. |
| 65 | func (frame *StackFrame) SourceLine() (string, error) { |