Dave Cheney 7 лет назад
Родитель
Сommit
308074fef0
3 измененных файлов с 4 добавлено и 8 удалено
  1. 1 1
      errors.go
  2. 1 5
      stack.go
  3. 2 2
      stack_test.go

+ 1 - 1
errors.go

@@ -82,7 +82,7 @@
 //
 //     if err, ok := err.(stackTracer); ok {
 //             for _, f := range err.StackTrace() {
-//                     fmt.Printf("%+s:%d", f)
+//                     fmt.Printf("%+s:%d\n", f, f)
 //             }
 //     }
 //

+ 1 - 5
stack.go

@@ -11,10 +11,6 @@ import (
 // Frame represents a program counter inside a stack frame.
 type Frame runtime.Frame
 
-// pc returns the program counter for this frame;
-// multiple frames may have the same PC value.
-func (f Frame) pc() uintptr { return runtime.Frame(f).PC }
-
 // file returns the full path to the file that contains the
 // function for this Frame's pc.
 func (f Frame) file() string {
@@ -61,7 +57,7 @@ func (f Frame) Format(s fmt.State, verb rune) {
 	case 'd':
 		fmt.Fprintf(s, "%d", f.line())
 	case 'n':
-		name := runtime.FuncForPC(f.pc()).Name()
+		name := runtime.Frame(f).Function
 		io.WriteString(s, funcname(name))
 	case 'v':
 		f.Format(s, 's')

+ 2 - 2
stack_test.go

@@ -10,12 +10,12 @@ var initpc = caller()
 
 type X struct{}
 
-//go:noinline
+// val returns a Frame pointing to itself.
 func (x X) val() Frame {
 	return caller()
 }
 
-//go:noinline
+// ptr returns a Frame pointing to itself.
 func (x *X) ptr() Frame {
 	return caller()
 }