Encode encodes value v and stores its representation in n. See the documentation for Marshal for details about the conversion of Go values into YAML.
(v interface{})
| 257 | // See the documentation for Marshal for details about the |
| 258 | // conversion of Go values into YAML. |
| 259 | func (n *Node) Encode(v interface{}) (err error) { |
| 260 | defer handleErr(&err) |
| 261 | e := newEncoder() |
| 262 | defer e.destroy() |
| 263 | e.marshalDoc("", reflect.ValueOf(v)) |
| 264 | e.finish() |
| 265 | p := newParser(e.out) |
| 266 | p.textless = true |
| 267 | defer p.destroy() |
| 268 | doc := p.parse() |
| 269 | *n = *doc.Content[0] |
| 270 | return nil |
| 271 | } |
| 272 | |
| 273 | // SetIndent changes the used indentation used when encoding. |
| 274 | func (e *Encoder) SetIndent(spaces int) { |