MCPcopy
hub / github.com/go-yaml/yaml / Decode

Method Decode

yaml.go:142–154  ·  view source on GitHub ↗

Decode decodes the node and stores its data into the value pointed to by v. See the documentation for Unmarshal for details about the conversion of YAML into a Go value.

(v interface{})

Source from the content-addressed store, hash-verified

140// See the documentation for Unmarshal for details about the
141// conversion of YAML into a Go value.
142func (n *Node) Decode(v interface{}) (err error) {
143 d := newDecoder()
144 defer handleErr(&err)
145 out := reflect.ValueOf(v)
146 if out.Kind() == reflect.Ptr && !out.IsNil() {
147 out = out.Elem()
148 }
149 d.unmarshal(n, out)
150 if len(d.terrors) > 0 {
151 return &TypeError{d.terrors}
152 }
153 return nil
154}
155
156func unmarshal(in []byte, out interface{}, strict bool) (err error) {
157 defer handleErr(&err)

Callers 9

TestSetStringMethod · 0.95
TestDecoderReadErrorMethod · 0.45
TestDecoderErrorsMethod · 0.45
UnmarshalYAMLMethod · 0.45
UnmarshalYAMLMethod · 0.45
UnmarshalYAMLMethod · 0.45
TestNodeEncodeDecodeMethod · 0.45

Calls 3

newDecoderFunction · 0.85
handleErrFunction · 0.85
unmarshalMethod · 0.80

Tested by 9

TestSetStringMethod · 0.76
TestDecoderReadErrorMethod · 0.36
TestDecoderErrorsMethod · 0.36
UnmarshalYAMLMethod · 0.36
UnmarshalYAMLMethod · 0.36
UnmarshalYAMLMethod · 0.36
TestNodeEncodeDecodeMethod · 0.36