MCPcopy Create free account
hub / github.com/apache/devlake / Decode

Function Decode

backend/helpers/pluginhelper/api/mapstructure.go:126–137  ·  view source on GitHub ↗

Decode decodes `source` into `target`. Pass an optional validator to validate the target.

(source interface{}, target interface{}, vld *validator.Validate)

Source from the content-addressed store, hash-verified

124
125// Decode decodes `source` into `target`. Pass an optional validator to validate the target.
126func Decode(source interface{}, target interface{}, vld *validator.Validate) errors.Error {
127 target = models.UnwrapObject(target)
128 if err := mapstructure.Decode(source, &target); err != nil {
129 return errors.Default.Wrap(err, "error decoding map into target type")
130 }
131 if vld != nil {
132 if err := vld.Struct(target); err != nil {
133 return errors.Default.Wrap(err, "error validating target")
134 }
135 }
136 return nil
137}

Callers 3

mergeMethod · 0.70
encodeTaskOptionsFunction · 0.70
DecodeStructFunction · 0.70

Calls 1

WrapMethod · 0.80

Tested by

no test coverage detected