Open mwhudson opened 8 years ago
One fix would be to not probe for MarshalYAML on anonymous fields -- it doesn't make a great deal of sense I think?
FWIW, encoding/json will only call MarshalJSON on an anonymous field when there's exactly one anonymous field. MarshalJSON on embedded types is ignored when there's more than one.
I'm not convinced honouring MarshalJSON/MarshalYAML is a good idea for any anonymous field as this means the contents of the containing struct aren't included in the YAML output.
panics with "panic: reflect.Value.Interface: cannot return value obtained from unexported field or method"
This is down to the call of .Interface() on f.bar that marshal() does before seeing if it implements the MarshalYAML method. The rules around whether embedded non-exported types count as exported or not changed in Go 1.6 -- this might count as a bug upstream, or missing API, or something (my head cold is too strong to think through all the issues today).