Is there any proposal in Go 2.0 to remove the promotion of methods on 
embedded struct fields or do you think it's a good idea ? For example in 
the code below if someone marshals `Pack`, only `Animal` is actually 
marshalled. Cat field is skipped. If he wants to marshal Cat as well the 
developer must write an additional wrapper method(MarshalJSON) on `Pack` 
and any other struct that embeds `Animal`. This becomes an even bigger 
issue if you create types dynamically (using reflect). Actually I believe 
reflect.StructOf is actually broken because of this feature (i.e. it panics 
if the embedded type has methods).


 type Pack struct{
     Animal
     Cat Cat
 }

 func (a *Animal)MarshalJSON()([]byte, error){
     // custom animal marshalling
 }

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/4366cedc-5833-4bb5-add5-8d96b86a83c5n%40googlegroups.com.

Reply via email to