MCPcopy
hub / github.com/mitchellh/mapstructure / DecodeHookExec

Function DecodeHookExec

decode_hooks.go:41–55  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

39// since it'll naturally degrade to the older backwards compatible DecodeHookFunc
40// that took reflect.Kind instead of reflect.Type.
41func 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.

Calls 1

typedDecodeHookFunction · 0.85

Used in the wild real call sites across dependent graphs

searching dependent graphs…