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: Couldn't unmarshal when inline struct's name is same with its attribute. #332

Closed
kitagry opened this issue Dec 19, 2022 · 1 comment · Fixed by #335
Closed

Bug: Couldn't unmarshal when inline struct's name is same with its attribute. #332

kitagry opened this issue Dec 19, 2022 · 1 comment · Fixed by #335

Comments

@kitagry
Copy link
Contributor

kitagry commented Dec 19, 2022

Hi, @goccy. I found the following bug, Thank you!

type Test struct {
	Weight `yaml:",inline"`
}

type Weight struct {
	Weight float64 `yaml:"weight"`
}

func main() {
	data := []byte(`weight: 0.7`)
	var test Test
	_ = yaml.Unmarshal(data, &test)
	fmt.Println(test)
}

expect:

{{0.7}}

actual

{{0}}
@kitagry
Copy link
Contributor Author

kitagry commented Dec 19, 2022

Thank you for the quick fix!

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.

1 participant