123456789101112131415161718192021222324252627282930 |
- package caller
- import "runtime"
- func CallFilePath() string {
- _, file, _, ok := runtime.Caller(1)
- if !ok {
- return "Unknown"
- }
- return file
- }
- func CallFunctionName() string {
- pc, _, _, ok := runtime.Caller(1)
- if !ok {
- return "Unknown"
- }
- return runtime.FuncForPC(pc).Name()
- }
- func CallLineNo() int {
- _, _, line, ok := runtime.Caller(1)
- if !ok {
- return 0
- }
- return line
- }
|