| 154 | } |
| 155 | |
| 156 | func unmarshal(in []byte, out interface{}, strict bool) (err error) { |
| 157 | defer handleErr(&err) |
| 158 | d := newDecoder() |
| 159 | p := newParser(in) |
| 160 | defer p.destroy() |
| 161 | node := p.parse() |
| 162 | if node != nil { |
| 163 | v := reflect.ValueOf(out) |
| 164 | if v.Kind() == reflect.Ptr && !v.IsNil() { |
| 165 | v = v.Elem() |
| 166 | } |
| 167 | d.unmarshal(node, v) |
| 168 | } |
| 169 | if len(d.terrors) > 0 { |
| 170 | return &TypeError{d.terrors} |
| 171 | } |
| 172 | return nil |
| 173 | } |
| 174 | |
| 175 | // Marshal serializes the value provided into a YAML document. The structure |
| 176 | // of the generated document will reflect the structure of the value itself. |