You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I am trying to parse a Yaml file with yaml.v3 and do some modifications on the nodes but when I am writing back the content to a file, the yaml encoder adds an extra merge tag (!!merge) wherever i have used <<.
func main() {
sourceYaml := `
demo:
- name: some_name
location:
country:
meta_data: &meta_data
name: some_place
description: "name of a place"
<<: *meta_data`
node := yaml.Node{}
err := yaml.Unmarshal([]byte(sourceYaml), &node)
if err != nil {
log.Fatalf(err.Error())
os.Exit(1)
}
var b bytes.Buffer
yamlEncoder := yaml.NewEncoder(&b)
err = yamlEncoder.Encode(&node)
if err != nil {
log.Fatalf(err.Error())
os.Exit(1)
}
fmt.Println(b.String())
err = os.WriteFile("test.yaml", b.Bytes(), 0o664)
if err != nil {
log.Fatalf(err.Error())
os.Exit(1)
}
}
Above code prints
demo:
- name: some_name
location:
country:
meta_data: &meta_data
name: some_place
description: "name of a place"
!!merge <<: *meta_data
Can you please check this?
Thanks
The text was updated successfully, but these errors were encountered:
Hi,
I am trying to parse a Yaml file with yaml.v3 and do some modifications on the nodes but when I am writing back the content to a file, the yaml encoder adds an extra merge tag (
!!merge
) wherever i have used<<
.Above code prints
Can you please check this?
Thanks
The text was updated successfully, but these errors were encountered: