()
| 71 | } |
| 72 | |
| 73 | func (frame *StackFrame) sourceLine() (string, error) { |
| 74 | if frame.LineNumber <= 0 { |
| 75 | return "???", nil |
| 76 | } |
| 77 | |
| 78 | file, err := os.Open(frame.File) |
| 79 | if err != nil { |
| 80 | return "", err |
| 81 | } |
| 82 | defer file.Close() |
| 83 | |
| 84 | scanner := bufio.NewScanner(file) |
| 85 | currentLine := 1 |
| 86 | for scanner.Scan() { |
| 87 | if currentLine == frame.LineNumber { |
| 88 | return string(bytes.Trim(scanner.Bytes(), " \t")), nil |
| 89 | } |
| 90 | currentLine++ |
| 91 | } |
| 92 | if err := scanner.Err(); err != nil { |
| 93 | return "", err |
| 94 | } |
| 95 | |
| 96 | return "???", nil |
| 97 | } |
| 98 | |
| 99 | func packageAndName(fn *runtime.Func) (string, string) { |
| 100 | name := fn.Name() |
no outgoing calls
no test coverage detected