How I can check that some variable in golang has type func
, like this:
func A() {}
func main() {
variable := A
isFunc := IsFunc(variable) // true or false
}
How I can check that some variable in golang has type func
, like this:
func A() {}
func main() {
variable := A
isFunc := IsFunc(variable) // true or false
}
func IsFunc(v interface{}) bool {
return reflect.TypeOf(v).Kind() == reflect.Func
}