-
Notifications
You must be signed in to change notification settings - Fork 212
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
Slices of structs are not properly reset when unmarshalling #931
Labels
bug
Issues describing a bug in go-toml.
Comments
Good catch, thank you for the bug report! The intent is to match |
pelletier
added a commit
that referenced
this issue
Feb 27, 2024
When decoding into a non-empty slice, it needs to be emptied so that only the tables contained in the document are present in the resulting value. Arrays are not impacted because their unmarshal offset is tracked separately. Fixes #931
pelletier
added a commit
that referenced
this issue
Feb 27, 2024
When decoding into a non-empty slice, it needs to be emptied so that only the tables contained in the document are present in the resulting value. Arrays are not impacted because their unmarshal offset is tracked separately. Fixes #931
@kkoreilly I've merged #934, which should address your issue. Let me know if it worked, feel free to re-open this issue if not! |
It worked, thank you! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
When unmarshalling a slice of structs (array of tables in TOML terminology) into a Go slice, any elements already present in the slice are not reset, leading to compounding slices. This did not happen in v1.
To Reproduce
main.go
:slice.toml
:Expected behavior
As stated in the code, I expected
{[{c} {d}]}
but got{[{a} {b} {c} {d}]}
.Versions
Additional context
As stated above, I have confirmed that this issue did not happen in v1.
The text was updated successfully, but these errors were encountered: