reflect helpers
(t reflect.Type, expected reflect.Kind)
| 1010 | // reflect helpers |
| 1011 | |
| 1012 | func baseType(t reflect.Type, expected reflect.Kind) (reflect.Type, error) { |
| 1013 | t = reflectx.Deref(t) |
| 1014 | if t.Kind() != expected { |
| 1015 | return nil, fmt.Errorf("expected %s but got %s", expected, t.Kind()) |
| 1016 | } |
| 1017 | return t, nil |
| 1018 | } |
| 1019 | |
| 1020 | // fieldsByName fills a values interface with fields from the passed value based |
| 1021 | // on the traversals in int. If ptrs is true, return addresses instead of values. |