mirror of
https://github.com/fleetdm/fleet
synced 2026-05-06 14:58:33 +00:00
15 lines
376 B
Go
15 lines
376 B
Go
package test
|
|
|
|
import (
|
|
"reflect"
|
|
"runtime"
|
|
"strings"
|
|
)
|
|
|
|
// FunctionName returns the name of the function provided as the argument.
|
|
// Behavior is undefined if a non-function is passed.
|
|
func FunctionName(f interface{}) string {
|
|
fullName := runtime.FuncForPC(reflect.ValueOf(f).Pointer()).Name()
|
|
elements := strings.Split(fullName, ".")
|
|
return elements[len(elements)-1]
|
|
}
|