Source file
test/fixedbugs/issue21879.go
1
2
3
4
5
6
7 package main
8
9 import (
10 "runtime"
11 )
12
13 func main() {
14 println(caller().frame.Function)
15
16
17
18 println(caller().name())
19 }
20
21 func caller() call {
22 var pcs [3]uintptr
23 n := runtime.Callers(1, pcs[:])
24 frames := runtime.CallersFrames(pcs[:n])
25 frame, _ := frames.Next()
26 frame, _ = frames.Next()
27
28 return call{frame: frame}
29 }
30
31 type call struct {
32 frame runtime.Frame
33 }
34
35 func (c call) name() string {
36 return c.frame.Function
37 }
38
View as plain text