mirror of
https://github.com/MontFerret/ferret.git
synced 2024-12-14 11:23:02 +02:00
26 lines
388 B
Go
26 lines
388 B
Go
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.Struct,
|
|
reflect.Func,
|
|
reflect.Interface,
|
|
reflect.Chan,
|
|
reflect.UnsafePointer:
|
|
return val.IsNil()
|
|
case reflect.Invalid:
|
|
return true
|
|
default:
|
|
return false
|
|
}
|
|
}
|