Skip to content
This repository was archived by the owner on Dec 1, 2021. It is now read-only.

Commit 42ce1b6

Browse files
authored
Remove Frame methods (#185)
errors.Frame is convertable from/to a runtime.Frame and know how to print itself. Signed-off-by: Dave Cheney <[email protected]>
1 parent 308074f commit 42ce1b6

File tree

1 file changed

+6
-18
lines changed

1 file changed

+6
-18
lines changed

stack.go

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,6 @@ import (
1111
// Frame represents a program counter inside a stack frame.
1212
type Frame runtime.Frame
1313

14-
// file returns the full path to the file that contains the
15-
// function for this Frame's pc.
16-
func (f Frame) file() string {
17-
file := runtime.Frame(f).File
18-
if file == "" {
19-
return "unknown"
20-
}
21-
return file
22-
}
23-
24-
// line returns the line number of source code of the
25-
// function for this Frame's pc.
26-
func (f Frame) line() int {
27-
return runtime.Frame(f).Line
28-
}
29-
3014
// Format formats the frame according to the fmt.Formatter interface.
3115
//
3216
// %s source file
@@ -52,10 +36,14 @@ func (f Frame) Format(s fmt.State, verb rune) {
5236
fmt.Fprintf(s, "%s\n\t%s", fn.Name(), file)
5337
}
5438
default:
55-
io.WriteString(s, path.Base(f.file()))
39+
file := runtime.Frame(f).File
40+
if file == "" {
41+
file = "unknown"
42+
}
43+
io.WriteString(s, path.Base(file))
5644
}
5745
case 'd':
58-
fmt.Fprintf(s, "%d", f.line())
46+
fmt.Fprintf(s, "%d", runtime.Frame(f).Line)
5947
case 'n':
6048
name := runtime.Frame(f).Function
6149
io.WriteString(s, funcname(name))

0 commit comments

Comments
 (0)