Suppose instead of `json:"s,string"` you had typed `json:"s,omitemptyy"` 
when you meant to type `json:"s,omitempty"`. Would you want to be told that 
you had an error in your struct tag? In general Go has a fail-fast 
philosophy to help prevent mistakes from persisting in a system unnoticed 
for a long time. It is this philosophy that warrants producing an error 
when the encoding/json package encounters an invalid json: struct tag.

Chris

On Thursday, December 15, 2016 at 8:32:03 AM UTC-5, Sathish VJ wrote:
>
> I have a struct that maps json of type string to a string.  
> S string `json:"s,string"`
>
> When run with that, it gives me the error:
> Error: json: invalid use of ,string struct tag, trying to unmarshal 
> "hello" into string
>
> I know that it is not really required.  But does it have to error out?
> Is the current behavior planned so for any reason?  I was thinking that 
> it's quite ok to over-specify the type here and the stand library would 
> ignore it.
>
> Full code: https://play.golang.org/p/gepaK1GsTC 
>

-- 
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