DecodeHookExec executes the given decode hook. This should be used since it'll naturally degrade to the older backwards compatible DecodeHookFunc that took reflect.Kind instead of reflect.Type.
( raw DecodeHookFunc, from reflect.Value, to reflect.Value)
| 39 | // since it'll naturally degrade to the older backwards compatible DecodeHookFunc |
| 40 | // that took reflect.Kind instead of reflect.Type. |
| 41 | func DecodeHookExec( |
| 42 | raw DecodeHookFunc, |
| 43 | from reflect.Value, to reflect.Value) (interface{}, error) { |
| 44 | |
| 45 | switch f := typedDecodeHook(raw).(type) { |
| 46 | case DecodeHookFuncType: |
| 47 | return f(from.Type(), to.Type(), from.Interface()) |
| 48 | case DecodeHookFuncKind: |
| 49 | return f(from.Kind(), to.Kind(), from.Interface()) |
| 50 | case DecodeHookFuncValue: |
| 51 | return f(from, to) |
| 52 | default: |
| 53 | return nil, errors.New("invalid decode hook signature") |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | // ComposeDecodeHookFunc creates a single DecodeHookFunc that |
| 58 | // automatically composes multiple DecodeHookFuncs. |
searching dependent graphs…