ast.Merge error `cannot merge Mapping into Anchor`
rjshrjndrn opened this issue · comments
Hi,
First of all, thank you for this amazing library.
I'm trying to merge 2 yamls, and getting error cannot merge Mapping into Anchor
. I tried to search in the docs, and in repo to be in vein.
I'm getting started with golang. So can't crack very deep things 😬
Appreciate any help.
Code
package main
import (
"fmt"
"strings"
"github.com/goccy/go-yaml"
"github.com/goccy/go-yaml/parser"
)
func main() {
original := `
chalice: &chalice
env:
environment: dev
cloud: AWS
other:
- hey
- hello
global:
chalice: *chalice
`
override := `
chalice: &chalice
env:
environment: production
jwt_enabled: false
global:
chalice: *chalice
`
orig, err := parser.ParseBytes([]byte(original), 0)
if err != nil {
fmt.Println("panic")
panic(err)
}
path, err := yaml.PathString("$.chalice")
if err != nil {
panic(err)
}
err = path.MergeFromReader(orig, strings.NewReader(override))
if err != nil {
panic(err)
}
}
error
❯ go run main.go
panic: cannot merge Mapping into Anchor
goroutine 1 [running]:
main.main()
/tmp/tmp_m/main.go:48 +0xc5
exit status 2