mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 17:05:18 +00:00
7f757d3144
Cleans up some repetition in tests.
16 lines
376 B
Go
16 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]
|
|
}
|