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

[BUG]: Aliases does not unmarshal (mapping key "<<" already defined ...) #966

Open
zombieleet opened this issue May 25, 2023 · 1 comment · May be fixed by #976
Open

[BUG]: Aliases does not unmarshal (mapping key "<<" already defined ...) #966

zombieleet opened this issue May 25, 2023 · 1 comment · May be fixed by #976

Comments

@zombieleet
Copy link

I am currently using the v3 of go-yaml , the problem is that unmarshalling multiple alias throws mapping key "<<" already defined at line 10. Below is the example code and yaml file

package main

import (
	"fmt"
	"log"
	"os"

	"gopkg.in/yaml.v3"
)

type Foo struct {
	Foo map[string]interface{} `yaml:"foo"`
}

func main() {

	file, err := os.Open("./test.yaml")

	if err != nil {
		log.Fatal(err)
	}

	x, _ := file.Stat()

	content := make([]byte, x.Size())

	_, err = file.Read(content)

	if err != nil {
		log.Fatal(err)
	}

	c := Foo{}

	err = yaml.Unmarshal(content, &c)

	if err != nil {
		log.Fatal(err)
	}

	fmt.Println(c)
}
reuse:
  - &reuse
    bar: "baz"

reuse2:
  - &reuse2
    baz: "foobar"

foo:
  <<: *reuse
  <<: *reuse2
@perlpunk
Copy link

See #918

@moskyb moskyb linked a pull request Jul 21, 2023 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants