-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Description
The rules for struct identity require that two identical structs have identical tags.
This plays into the rules for assignments and conversions of structs in unfortunate ways:
There appears to be no way to assign or even convert a struct with tags to another struct with different or no tags, wether that other struct is named or unnamed:
http://play.golang.org/p/6FZcWSIc9w
I think we're overly restrictive here. For instance, if I wanted to convert a struct with json tags to a struct with tags for some other encoding (to convert from one encoding to another), I actually have to copy all the fields by hand.
This seems counter-intuitive. I would have expected that I could go via an unnamed struct, or at the very least use an explicit conversion.
I'm thinking that perhaps we should relax the rules here. One might be to remove again the requirement of identical tags for struct identity (simplest); or perhaps to relax the rules for assignments and conversions of structs.