This is sort of surprising though: https://play.golang.org/p/mjfkzIqAo_b

On Mon, 2018-01-22 at 10:20 -0800, C Banning wrote:
> From the Language Specification - 
> 
> A field declared with a type but no explicit field name is called an
> *embedded 
> field*. An embedded field must be specified as a type name T or as a 
> pointer to a non-interface type name *T, and T itself may not be a
> pointer 
> type. The unqualified type name acts as the field name.
> 
> // A struct with four embedded fields of types T1, *T2, P.T3 and
> *P.T4
> struct {
>         T1        // field name is T1
>         *T2       // field name is T2
>         P.T3      // field name is T3
>         *P.T4     // field name is T4
>         x, y int  // field names are x and y
> }
> 
> 
> From the encoding/json#Marshal documentation - 
> 
> Struct values encode as JSON objects. Each exported struct field
> becomes a 
> member of the object, using the field name as the object key, unless
> the 
> field is omitted for one of the reasons given below.
> 

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