Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anchors are broken for MapSlice #344

Closed
sam701 opened this issue Mar 19, 2018 · 1 comment
Closed

Anchors are broken for MapSlice #344

sam701 opened this issue Mar 19, 2018 · 1 comment

Comments

@sam701
Copy link

sam701 commented Mar 19, 2018

Unmarshal produces wrong output for yaml.MapSlice. Here is the code:

package main

import (
	"log"

	"gopkg.in/yaml.v2"
)

var content = `
a1:
  f1: value1
  <<: &anchor
    f2: value2
  
a2:
  f3: value3
  <<: *anchor
`

func main() {
	var result map[interface{}]interface{}
	yaml.Unmarshal([]byte(content), &result)
	log.Println(result)

	var result2 yaml.MapSlice
	yaml.Unmarshal([]byte(content), &result2)
	log.Println(result2)
}

Output:

2018/03/19 10:37:04 map[a1:map[f1:value1 f2:value2] a2:map[f3:value3 f2:value2]]
2018/03/19 10:37:04 [{a1 [{f1 value1}]} {a2 [{f3 value3}]}]

f2 is missing for yaml.MapSlice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants