go-yaml
go-yaml copied to clipboard
The documentation for Encode is wrong - it doesn't print document separators
Encode writes the YAML encoding of v to the stream. If multiple items are encoded to the stream, the second and subsequent document will be preceded with a "---" document separator, but the first will not.
Test:
buf := new(bytes.Buffer)
encoder := yaml.NewEncoder(buf)
encoder.Encode(1)
encoder.Encode(2)
fmt.Println(buf.String())
Expected:
1
---
2
Actual:
1
2
Isn't then the encoding wrong instead of the docs wrong?