On Mon, Jun 2, 2014 at 11:00 AM, Matt Harden <
matt....@gmail.com> wrote:
> Sorry, I forgot to reply-all.
>
> It all comes down to addressability. json.Marshal accepts an interface{}
> value. When you pass a struct as an interface{}, the resulting value is not
> addressable. If it's not addressable, you can't take its address using the &
> operator, and you can't take the address of a field within it either. See
> this example
http://play.golang.org/p/pwZOzMaM4O.
>
> When json.Marshal is passed a pointer to a struct, then when marshaling a
> field, it looks to see if the pointer to the field implements the
> json.Marshaler interface. If it doesn't have a pointer, it can only look for
> a non-pointer implementation of json.Marshaler, because it doesn't have a
> pointer to the field.