go-yaml icon indicating copy to clipboard operation
go-yaml copied to clipboard

The documentation for Encode is wrong - it doesn't print document separators

Open vikstrous2 opened this issue 3 years ago • 1 comments

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

vikstrous2 avatar Nov 06 '21 03:11 vikstrous2

Isn't then the encoding wrong instead of the docs wrong?

timo-klarshift avatar Jan 14 '22 17:01 timo-klarshift