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

Function Decode

mapstructure.go:306–318  ·  mapstructure.go::Decode

Decode takes an input structure and uses reflection to translate it to the output structure. output must be a pointer to a map or struct.

(input interface{}, output interface{})

Source from the content-addressed store, hash-verified

304// Decode takes an input structure and uses reflection to translate it to
305// the output structure. output must be a pointer to a map or struct.
306func Decode(input interface{}, output interface{}) error {
307 config := &DecoderConfig{
308 Metadata: nil,
309 Result: output,
310 }
311
312 decoder, err := NewDecoder(config)
313 if err != nil {
314 return err
315 }
316
317 return decoder.Decode(input)
318}
319
320// WeakDecode is the same as Decode but is shorthand to enable
321// WeaklyTypedInput. See DecoderConfig for more info.

Callers 15

TestBasicTypesFunction · 0.85
TestBasic_IntWithFloatFunction · 0.85
TestBasic_MergeFunction · 0.85
TestBasic_StructFunction · 0.85
TestDecode_BasicSquashFunction · 0.85
TestDecode_EmbeddedFunction · 0.85
TestDecode_EmbeddedSliceFunction · 0.85
TestDecode_EmbeddedArrayFunction · 0.85

Calls 2

DecodeMethod · 0.95
NewDecoderFunction · 0.85

Tested by 15

TestBasicTypesFunction · 0.68
TestBasic_IntWithFloatFunction · 0.68
TestBasic_MergeFunction · 0.68
TestBasic_StructFunction · 0.68
TestDecode_BasicSquashFunction · 0.68
TestDecode_EmbeddedFunction · 0.68
TestDecode_EmbeddedSliceFunction · 0.68
TestDecode_EmbeddedArrayFunction · 0.68