I don't think your analogy is right.  The example you gave is an error, as 
if we wrote: var i = float64("hello")
Whereas, the code I wrote is just being explicit when it is ok to be 
implicit.  So, more like we wrote: 
var i1 = 3.142
var i2 = float64(3.142)
i3 := float64(3.142)

The float64 casting is unnecessary in the latter two cases, but it isn't an 
error.

On Thursday, 15 December 2016 21:01:11 UTC+5:30, Chris Hines wrote:
>
> 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