Closed xsteadfastx closed 1 year ago
Solved on slack. https://gophers.slack.com/archives/C029RQSEE/p1684172502164089. For anyone with a similar issue, check out the new TextMarshaler example: https://github.com/pelletier/go-toml/blob/v2/example_text_marshaling_test.go
Hey would you mind pasting the information from the slack thread to here. Running into the exact same issue trying to parse a TOML table and the UnmarshalText
method is never called:
https://go.dev/play/p/YlQNP2_tV9i
However, if the raw toml is not a table, then it panics as expected: https://go.dev/play/p/R3pAKUsMYyB
the string needs to be a custom type with the UnmarshalText
method.
Indeed, the field that's being deserialized (the string) needs to implement the interface. For example https://go.dev/play/p/1R00L9cRHB5
Describe the bug I try to add a custom TextUnmarshaler for a struct. It just gets ignored. it also can be that im doing something wrong. i would love to get some help :)
To Reproduce
https://go.dev/play/p/7d91gwsUc4K
Expected behavior That Value gets set to 78 and print
foo
.Versions