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

Method Decode

yaml.go:119–136  ·  view source on GitHub ↗

Decode reads the next YAML-encoded value from its input and stores it in 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

117// See the documentation for Unmarshal for details about the
118// conversion of YAML into a Go value.
119func (dec *Decoder) Decode(v interface{}) (err error) {
120 d := newDecoder()
121 d.knownFields = dec.knownFields
122 defer handleErr(&err)
123 node := dec.parser.parse()
124 if node == nil {
125 return io.EOF
126 }
127 out := reflect.ValueOf(v)
128 if out.Kind() == reflect.Ptr && !out.IsNil() {
129 out = out.Elem()
130 }
131 d.unmarshal(node, out)
132 if len(d.terrors) > 0 {
133 return &TypeError{d.terrors}
134 }
135 return nil
136}
137
138// Decode decodes the node and stores its data into the value pointed to by v.
139//

Callers 2

TestDecoderMethod · 0.95

Calls 4

newDecoderFunction · 0.85
handleErrFunction · 0.85
parseMethod · 0.80
unmarshalMethod · 0.80

Tested by 2

TestDecoderMethod · 0.76