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

Function OrComposeDecodeHookFunc

decode_hooks.go:82–100  ·  view source on GitHub ↗

OrComposeDecodeHookFunc executes all input hook functions until one of them returns no error. In that case its value is returned. If all hooks return an error, OrComposeDecodeHookFunc returns an error concatenating all error messages.

(ff ...DecodeHookFunc)

Source from the content-addressed store, hash-verified

80// OrComposeDecodeHookFunc executes all input hook functions until one of them returns no error. In that case its value is returned.
81// If all hooks return an error, OrComposeDecodeHookFunc returns an error concatenating all error messages.
82func OrComposeDecodeHookFunc(ff ...DecodeHookFunc) DecodeHookFunc {
83 return func(a, b reflect.Value) (interface{}, error) {
84 var allErrs string
85 var out interface{}
86 var err error
87
88 for _, f := range ff {
89 out, err = DecodeHookExec(f, a, b)
90 if err != nil {
91 allErrs += err.Error() + "\n"
92 continue
93 }
94
95 return out, nil
96 }
97
98 return nil, errors.New(allErrs)
99 }
100}
101
102// StringToSliceHookFunc returns a DecodeHookFunc that converts
103// string to []string by splitting on the given sep.

Calls 2

DecodeHookExecFunction · 0.85
ErrorMethod · 0.80

Used in the wild real call sites across dependent graphs

searching dependent graphs…