go-toml
go-toml copied to clipboard
Fix UnmarshalTOML is not called when its underlying type is an array
This PR is for v1.
This resolves the issue where, if a type implements toml.Unmarshaler
but it has an array as its underlying type, the UnmarshalTOML
method won't be triggered.
Hi! Thank you for the patch! However v1 is not supported anymore and will not receive any update. Consider using go-toml v2 instead.
@pelletier Thanks for yor reminder. You can close this PR at your opinion.
I’m not using v2 (in fact, I just downgraded to v1 today) because and only because of the lack of missing toml.Unmarshaler interface.
Though there’s TextUnmarshaler, but it can only handle string fields. However, I want to (and need to) do more for historical reasons. The case is just that we have a field that needs to accept both a string and a string array. But in v2, there’s no way to implement it.
Is it possible to re-add the toml.Unmarshaler interface? It will do increase flexibility. And if you accept the feature, I can submit a PR to implement that.
Makes sense. I'd be happy to see a good patch to implement toml.Unmarshaler
for v2! I think it would also help others (https://github.com/pelletier/go-toml/issues/857).
@pelletier 👀 Okay, I will try to implement it!
@ImSingee created https://github.com/pelletier/go-toml/issues/873 with some thoughts on the topic, hopefully it's helpful!