Encode is a convenience function which will encode the given node to a byte slice.
()
| 9 | // Encode is a convenience function which will encode the given node to a byte |
| 10 | // slice. |
| 11 | func (n *Node) Encode() ([]byte, error) { |
| 12 | // All this is really so we can set indentation to 2 spaces. |
| 13 | buf := &bytes.Buffer{} |
| 14 | enc := yaml.NewEncoder(buf) |
| 15 | |
| 16 | enc.SetIndent(2) |
| 17 | |
| 18 | err := enc.Encode(n.Node) |
| 19 | |
| 20 | return buf.Bytes(), err |
| 21 | } |
no outgoing calls
no test coverage detected