IfaceIsNil returns true if interface or value represented by interface is nil
(it interface{})
| 39 | |
| 40 | // IfaceIsNil returns true if interface or value represented by interface is nil |
| 41 | func IfaceIsNil(it interface{}) bool { |
| 42 | if it == nil { |
| 43 | return true |
| 44 | } |
| 45 | v := reflect.ValueOf(it) |
| 46 | vk := v.Kind() |
| 47 | if vk == reflect.Ptr || vk == reflect.Interface || vk == reflect.Map || vk == reflect.Slice || vk == reflect.Func || vk == reflect.Chan { |
| 48 | return v.IsNil() |
| 49 | } |
| 50 | return false |
| 51 | } |
| 52 | |
| 53 | // NonPtrValue returns the non-pointer underlying value |
| 54 | func NonPtrValue(v reflect.Value) reflect.Value { |