-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
MarshalText interface is ignored on nested structs #959
Comments
NOTE: It appears as though the MarshalYAML() interface is also ignored on child / nested structs as well, as in the following example:
|
I did a bit more ad-hoc testing on this issue, and the problem seems to be related to whether the marshaller method takes a pointer or reference receiver. Using the sample code from above, if I have a struct that contains a reference to a value object, then the marshaller method needs to have a reference receiver:
Similarly, if I have a struct that contains a pointer to a value instead of a reference, the marshaller interface must use a pointer-receiver as in:
The issue then becomes, how can one implement a marshal implementation for a structure so as to allow both reference and pointer values to be serialized properly? |
I can confirm this is the case |
See #979 |
Given the following example structs:
If you attempt to marshal an instance of MyParent to YAML by doing something like this:
You get the following output:
Instead of the expected output of:
If, however, you attempt to marshal and instance of the MyChild struct directly, as in:
You get the expected output:
The text was updated successfully, but these errors were encountered: