From d56363987d920ee146a4d2a09f04dfa2c5e4ab9d Mon Sep 17 00:00:00 2001 From: Dave Cheney Date: Sat, 5 Jan 2019 19:59:15 +1100 Subject: [PATCH] Remove Frame methods errors.Frame is convertable from/to a runtime.Frame and know how to print itself. Signed-off-by: Dave Cheney --- stack.go | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/stack.go b/stack.go index 23321e9b..582b3e97 100644 --- a/stack.go +++ b/stack.go @@ -11,22 +11,6 @@ import ( // Frame represents a program counter inside a stack frame. type Frame runtime.Frame -// file returns the full path to the file that contains the -// function for this Frame's pc. -func (f Frame) file() string { - file := runtime.Frame(f).File - if file == "" { - return "unknown" - } - return file -} - -// line returns the line number of source code of the -// function for this Frame's pc. -func (f Frame) line() int { - return runtime.Frame(f).Line -} - // Format formats the frame according to the fmt.Formatter interface. // // %s source file @@ -52,10 +36,14 @@ func (f Frame) Format(s fmt.State, verb rune) { fmt.Fprintf(s, "%s\n\t%s", fn.Name(), file) } default: - io.WriteString(s, path.Base(f.file())) + file := runtime.Frame(f).File + if file == "" { + file = "unknown" + } + io.WriteString(s, path.Base(file)) } case 'd': - fmt.Fprintf(s, "%d", f.line()) + fmt.Fprintf(s, "%d", runtime.Frame(f).Line) case 'n': name := runtime.Frame(f).Function io.WriteString(s, funcname(name))