unwind pointers, etc to find either the value or flag indicating was nil
(v reflect.Value)
| 49 | |
| 50 | // unwind pointers, etc to find either the value or flag indicating was nil |
| 51 | func findValue(v reflect.Value) (reflect.Value, bool) { |
| 52 | for ; v.Kind() == reflect.Ptr || v.Kind() == reflect.Interface; v = v.Elem() { |
| 53 | if v.IsNil() { |
| 54 | return v, true |
| 55 | } |
| 56 | if v.Kind() == reflect.Interface && v.NumMethod() > 0 { |
| 57 | break |
| 58 | } |
| 59 | } |
| 60 | return v, false |
| 61 | } |
| 62 | |
| 63 | var zero reflect.Value |
| 64 |