pelletier / go-toml

Go library for the TOML file format
https://github.com/pelletier/go-toml
Other
1.68k stars 208 forks source link

Decode: assign empty struct to empty defined sections #879

Closed dbarrosop closed 1 year ago

dbarrosop commented 1 year ago

Fixes #878

Not sure what the gate in the patched method was intended to do but it was preventing from creating pointers to structs correctly when a section was defined. This change ensures that original_document == Marshal(Unmarsal(original_document) which isn't the case without this patch.

pelletier commented 1 year ago

Thanks a lot for the patch, and sorry for the delay! Not sure what that check was about either, but I think having round-trip equality is a good property to have.

pelletier commented 1 year ago

Looks like removing this check either made some code unused, or created untested cases. Do you mind taking a look and removing the code or adding relevant tests so that we are sure we don't miss anything? Otherwise, I can check next weekend.

dbarrosop commented 1 year ago

Sorry for the delay, I was travelling during the week. I tried looking into this but I am afraid I am not familiar enough with the codebase to understand why the coverage went down or how to increase it back. If this is something you could help with I'd really appreciate it. Thanks!

dbarrosop commented 1 year ago

@pelletier do you think you could help with the coverage, please?

pelletier commented 1 year ago

Done; thank you for the nudge!

dbarrosop commented 1 year ago

Awesome! Thanks for the help :)