https://golang.org/doc/go1.9#callersframes
()
| 68 | |
| 69 | // https://golang.org/doc/go1.9#callersframes |
| 70 | func GetCaller() (string, int) { |
| 71 | var pcs [32]uintptr |
| 72 | n := runtime.Callers(4, pcs[:]) |
| 73 | frames := runtime.CallersFrames(pcs[:n]) |
| 74 | |
| 75 | for { |
| 76 | frame, more := frames.Next() |
| 77 | file := frame.File |
| 78 | |
| 79 | if strings.Contains(file, "go/src/runtime/") { |
| 80 | continue |
| 81 | } |
| 82 | |
| 83 | // funcName is something like "github.com/kataras/iris.SomeFunc" |
| 84 | funcName := frame.Function |
| 85 | if !strings.HasPrefix(funcName, "github.com/kataras/iris/v12") { |
| 86 | return file, frame.Line |
| 87 | } |
| 88 | |
| 89 | if !more { |
| 90 | break |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | return "???", 0 |
| 95 | } |
no test coverage detected
searching dependent graphs…