You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
auth2/internal/util/util.go

23 lines
457 B
Go

package util
import (
"reflect"
"runtime"
"strings"
)
// ReflectFunctionName Guess Struct.Method from the given Function
func ReflectFunctionName(i interface{}) string {
switch v := i.(type) {
case string:
return v
default:
path := runtime.FuncForPC(reflect.ValueOf(i).Pointer()).Name()
// LTrim until the first /
path = path[strings.LastIndex(path, "/")+1:]
// Return after the next point
return path[strings.Index(path, ".")+1:]
}
}