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

[Question] Is there an option doesn't allow different type? #53

Closed
kitagry opened this issue Dec 10, 2019 · 1 comment · Fixed by #55
Closed

[Question] Is there an option doesn't allow different type? #53

kitagry opened this issue Dec 10, 2019 · 1 comment · Fixed by #55

Comments

@kitagry
Copy link
Sponsor Contributor

kitagry commented Dec 10, 2019

Currently, github.com/goccy/go-yaml is executed as follows.
Is there an option that doesn't allow this?

type st struct {
	A int `json:"a"`
}

func main() {
	d := yaml.NewDecoder(strings.NewReader("a: string"))  // different type
	var a st
	err := d.Decode(&a)
	fmt.Println(a.A)    // --> 0
	fmt.Println(err)    // --> nil (But I want error)
}
@kitagry kitagry changed the title [Question] Is there option doesn't allow different type? [Question] Is there an option doesn't allow different type? Dec 10, 2019
@goccy
Copy link
Owner

goccy commented Dec 10, 2019

Thank you for the report.
This behavior is not intended and I will fix as soon as possible .

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