1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-24 05:17:03 +00:00
Former-commit-id: 2b48b9b912e9eb8f5f2c6d413907dbfdae857e08
This commit is contained in:
Gerasimos (Makis) Maropoulos
2019-06-14 11:26:56 +03:00
parent 272566950d
commit 0f907a3dae
8 changed files with 87 additions and 23 deletions

View File

@@ -73,6 +73,7 @@ func IndirectValue(v reflect.Value) reflect.Value {
if k := v.Kind(); k == reflect.Ptr { //|| k == reflect.Interface {
return v.Elem()
}
return v
}
@@ -106,6 +107,17 @@ func IndirectType(typ reflect.Type) reflect.Type {
return typ
}
// IsNil same as `reflect.IsNil` but a bit safer to use, returns false if not a correct type.
func IsNil(v reflect.Value) bool {
k := v.Kind()
switch k {
case reflect.Chan, reflect.Func, reflect.Map, reflect.Ptr, reflect.UnsafePointer, reflect.Interface, reflect.Slice:
return v.IsNil()
default:
return false
}
}
func goodVal(v reflect.Value) bool {
switch v.Kind() {
case reflect.Chan, reflect.Func, reflect.Map, reflect.Ptr, reflect.Interface, reflect.Slice: