fix pointer receiver method expiression
This commit is contained in:
parent
422498af8d
commit
4077b6fdf0
@ -584,12 +584,7 @@ func getReflectTypeAndMethod(f interface{}) (controllerType reflect.Type, method
|
|||||||
panic("invalid number of param in")
|
panic("invalid number of param in")
|
||||||
}
|
}
|
||||||
|
|
||||||
// check the receiver implement ControllerInterface
|
|
||||||
controllerType = funcType.In(0)
|
controllerType = funcType.In(0)
|
||||||
_, ok := reflect.New(controllerType).Interface().(ControllerInterface)
|
|
||||||
if !ok {
|
|
||||||
panic(controllerType.String() + " is not implemented ControllerInterface")
|
|
||||||
}
|
|
||||||
|
|
||||||
// check controller has the method
|
// check controller has the method
|
||||||
_, exists := controllerType.MethodByName(method)
|
_, exists := controllerType.MethodByName(method)
|
||||||
@ -597,6 +592,16 @@ func getReflectTypeAndMethod(f interface{}) (controllerType reflect.Type, method
|
|||||||
panic(controllerType.String() + " has no method " + method)
|
panic(controllerType.String() + " has no method " + method)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check the receiver implement ControllerInterface
|
||||||
|
if controllerType.Kind() == reflect.Ptr {
|
||||||
|
controllerType = controllerType.Elem()
|
||||||
|
}
|
||||||
|
controller := reflect.New(controllerType)
|
||||||
|
_, ok := controller.Interface().(ControllerInterface)
|
||||||
|
if !ok {
|
||||||
|
panic(controllerType.String() + " is not implemented ControllerInterface")
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user