reflect.go 562 B

12345678910111213141516171819202122
  1. package mvc
  2. import (
  3. "reflect"
  4. )
  5. var baseControllerTyp = reflect.TypeOf((*BaseController)(nil)).Elem()
  6. func isBaseController(ctrlTyp reflect.Type) bool {
  7. return ctrlTyp.Implements(baseControllerTyp)
  8. }
  9. // indirectType returns the value of a pointer-type "typ".
  10. // If "typ" is a pointer, array, chan, map or slice it returns its Elem,
  11. // otherwise returns the typ as it's.
  12. func indirectType(typ reflect.Type) reflect.Type {
  13. switch typ.Kind() {
  14. case reflect.Ptr, reflect.Array, reflect.Chan, reflect.Map, reflect.Slice:
  15. return typ.Elem()
  16. }
  17. return typ
  18. }