Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
encoding/json: UnmarshalJSON not working consistently with struct embedding #39175
What version of Go are you using (
I got some answer from the community:
That means neither
We briefly discussed this on Slack, and I agree with @seankhliao that this is intended behavior, which is what he described in the quote above.
We can't make
I think the general answer here is - if you don't know what methods a named type has, or if it's maintained in an external module out of your control, you want to be careful about embedding it and gaining its methods. Because it might "take over" methods you don't declare yourself and affect printing, encoding, decoding, etc.
@magodo should we close this as "working as intended"?