Open MisterMX opened 3 years ago
When encoding a multi-document file, the headComment and footComment are not associated properly with the document root.
headComment
footComment
Example code:
package main import ( "bytes" "io" "log" yaml "gopkg.in/yaml.v3" ) const testYaml = `--- # head1 ab: cd # foot1 --- # head2 ab: cd # foot2 ` func main() { buf := bytes.NewBufferString(testYaml) dec := yaml.NewDecoder(buf) var node yaml.Node for { if err := dec.Decode(&node); err != nil { if err != io.EOF { log.Fatal(err) } break } log.Println("Head: ", node.HeadComment) log.Println("Foot: ", node.FootComment) log.Println("---") } log.Println("Done") }
Output:
Head: Foot: # head2 --- Head: Foot: # foot2 --- Done
I also ran into this issue when splitting yaml documents from helmfile.
When encoding a multi-document file, the
headComment
andfootComment
are not associated properly with the document root.Example code:
Output: