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

fields in embedded structure are not parsed #1062

Open
jotego opened this issue Dec 29, 2024 · 0 comments
Open

fields in embedded structure are not parsed #1062

jotego opened this issue Dec 29, 2024 · 0 comments

Comments

@jotego
Copy link

jotego commented Dec 29, 2024

type MacroEnabled struct{
    When    []string `yaml:"when"`
    Unless  []string `yaml:"unless"`
}

type BRAMBus_Ioctl struct {
    MacroEnabled
    Save    bool `yaml:"save"`
}

When unmarshing data, the fields When and Unless do not get filled. Replacing the embedded struct by explicit fields fixes the problem:

type BRAMBus_Ioctl struct {
    When    []string `yaml:"when"`
    Unless  []string `yaml:"unless"`
    Save    bool `yaml:"save"`
}

Embedding structures has a number of advantes in Go, such as getting instantly the methods of the embedded structure. It would be nice to support this feature.

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

1 participant