1
0
mirror of https://github.com/MontFerret/ferret.git synced 2024-12-16 11:37:36 +02:00
ferret/pkg/runtime/core/helpers.go

27 lines
407 B
Go
Raw Normal View History

2018-09-18 22:42:38 +02:00
package core
import "reflect"
func IsNil(input interface{}) bool {
val := reflect.ValueOf(input)
kind := val.Kind()
switch kind {
case reflect.Ptr,
reflect.Array,
reflect.Slice,
reflect.Map,
reflect.Func,
reflect.Interface,
reflect.Chan:
2018-09-18 22:42:38 +02:00
return val.IsNil()
case reflect.Struct,
reflect.UnsafePointer:
return false
2018-09-18 22:42:38 +02:00
case reflect.Invalid:
return true
default:
return false
}
}