On Sun, Jun 19, 2016 at 3:42 AM, 'Mihai B' via golang-nuts
<golang-nuts@googlegroups.com> wrote:
>
> I have a struct that needs to be marshalled/unmarshalled using various
> serialization formats(xml, json, name/value). The tags start to represent a
> considerable effort[0] so I'm wondering if this is a common use case and if
> a change[1] to the encoding packages to specify the tag key/selectors would
> be a bad idea. Another option would be to use a standard tag key as default
> (e.g. "encoding") but I think it may violate  the Go1 backward
> compatibility.
>
> Mihai.
>
>
> [0]
> type Payment struct {
> ActionType paypal.ActionType `query:"actionType,omitempty"
> json:"actionType,omitempty"  xml:"actionType,omitempty"`
> ReceiverList paypal.ReceiverList `query:"actionType,omitempty"
> json:"receiverList,omitempty"  xml:"receiverList,omitempty"`
> }
>
>
> [1] (dec *Decoder)SetTagKey(key string)

I could be wrong but to me this sounds like a special case problem.  I
don't think many people are going to run into cases where they need to
specify omitEmpty for multiple encoding formats.  I'm certainly not
opposed to simplification here, but I don't see how to simplify
matters without making the code more complex or harder to use for the
normal case.

Ian

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to