mirror of
https://github.com/kataras/iris.git
synced 2025-01-23 18:51:03 +01:00
3a46102d4d
Former-commit-id: eb395b06003ea9eae005a36c9c6be0ef63c4d41d
47 lines
995 B
Go
47 lines
995 B
Go
package mvc2
|
|
|
|
import "reflect"
|
|
|
|
func isContext(inTyp reflect.Type) bool {
|
|
return inTyp.String() == "context.Context" // I couldn't find another way; context/context.go is not exported.
|
|
}
|
|
|
|
func indirectVal(v reflect.Value) reflect.Value {
|
|
return reflect.Indirect(v)
|
|
}
|
|
|
|
func indirectTyp(typ reflect.Type) reflect.Type {
|
|
switch typ.Kind() {
|
|
case reflect.Ptr, reflect.Array, reflect.Chan, reflect.Map, reflect.Slice:
|
|
return typ.Elem()
|
|
}
|
|
return typ
|
|
}
|
|
|
|
func goodVal(v reflect.Value) bool {
|
|
switch v.Kind() {
|
|
case reflect.Chan, reflect.Func, reflect.Map, reflect.Ptr, reflect.Interface, reflect.Slice:
|
|
if v.IsNil() {
|
|
return false
|
|
}
|
|
}
|
|
|
|
return v.IsValid()
|
|
}
|
|
|
|
func isFunc(typ reflect.Type) bool {
|
|
return typ.Kind() == reflect.Func
|
|
}
|
|
|
|
func equalTypes(in reflect.Type, v reflect.Type) bool {
|
|
if in == v {
|
|
return true
|
|
}
|
|
// if accepts an interface, check if the given "v" type does
|
|
// implement this.
|
|
if in.Kind() == reflect.Interface {
|
|
return v.Implements(in)
|
|
}
|
|
return false
|
|
}
|