I am testing with HeadComment from a very simple code below:
package main
import (
"fmt"
"gopkg.in/yaml.v3"
)
type Person struct {
Name *yaml.Node
}
func main() {
nameNode := &yaml.Node{
Kind: yaml.ScalarNode,
HeadComment: "The name of a person",
Value: "Lily",
Style: yaml.DoubleQuotedStyle,
}
person := Person{
Name: nameNode,
}
dataInBytes, _ := yaml.Marshal(person)
fmt.Println(string(dataInBytes))
}
I am expecting to see the output like this:
# The name of a person
name: "Lily"
However, I got:
name: "Lily"
# The name of a person
A head comment becomes a foot comment. Anyone has ideas ? Thanks !