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{})
| 117 | // See the documentation for Unmarshal for details about the |
| 118 | // conversion of YAML into a Go value. |
| 119 | func (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 | // |