mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-16 05:24:20 +02:00
Make getting function name a utility function
This commit is contained in:
@@ -294,3 +294,15 @@ func SourceLoc(skip_frames ...int) string {
|
||||
}
|
||||
return "unknown"
|
||||
}
|
||||
|
||||
func FunctionName(a any) string {
|
||||
if a == nil {
|
||||
return "<nil>"
|
||||
}
|
||||
p := reflect.ValueOf(a).Pointer()
|
||||
f := runtime.FuncForPC(p)
|
||||
if f != nil {
|
||||
return f.Name()
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user