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

Merges not working as expected #1

Closed
torrance opened this issue Mar 6, 2014 · 1 comment
Closed

Merges not working as expected #1

torrance opened this issue Mar 6, 2014 · 1 comment

Comments

@torrance
Copy link

torrance commented Mar 6, 2014

I have the following yaml configuration:

default: &default
  user: "adm"
  file_perms: "664"

folders:
  - path: "/var"
    user: "www-data"
    dir_perms: "775"

  - path: "/var/site/"
    group: "www-editors"

  - <<: *default
    path: "/lib/folder2"

And I'm expected to be able to merge the key values for 'default' into the third folders list item.

My struct that I'm providing to the Unmarshal method looks like:

type config struct {
    Folders []*folder
}

type folder struct {
    Path      string
    User      string
    Uid       int
    Group     string
    Gid       int
    DirPerms  string `yaml:"dir_perms"`
    DirMode   os.FileMode
    FilePerms string `yaml:"file_perms"`
    FileMode  os.FileMode
    Children  folders
}

Note there's no 'default' key provided as I don't care about loading the default value, but I still would expect its keys to be merged into the folders list.

Am I doing something wrong, or does go-yaml not handle merges?

@niemeyer
Copy link
Contributor

That doesn't yet work indeed, but it should. Here is the documentation reference:

http://yaml.org/type/merge.html

vinzenz referenced this issue in vinzenz/yaml Nov 2, 2016
laverya pushed a commit to laverya/yaml that referenced this issue Sep 4, 2019
laverya pushed a commit to laverya/yaml that referenced this issue Sep 4, 2019
sylr referenced this issue in sylr/go-yaml May 16, 2021
Updates to yaml allowing decoding into structs and maintaining field positions and comments.
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