It seems to me that the use of JSON unmarshalling isn't
anything to do with your problem (copying interface variables), yes?
You can copy an interface variable with a simple assignment.
You get two variables that hold the same value.
But like any Go assignment, it copies pointers /as pointers/,
not making copies of the pointed-to thing. Similarly for
slices and maps and channels.
So if you copy a &Dog, you get another pointer to the same
Dog, and if you poke that Dog through one pointer, eg changing
their Name to Scamper, then you will see that new name when
you look through the other pointer.
Which is (part of) what's happening in your example, where in
a complicated way you change the single Dog's name to Beta.
There's only one Dog, the one you put into the map.
Does that help?
Chris
> --
> 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...@googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.
--
Chris "allusive" Dollin