On Tue, Mar 6, 2018 at 2:58 PM, Bharath Ram wrote:
> In that case, for a nested struct from top to bottom, all the values are
> copies as values, correct? i.e, string, int, float, array etc will be copied
> by value & map, slice, channel etc will be copied as pointers if they are
> initialized?
>
Thanks a lot!
On Mar 6, 2018 5:22 PM, "Burak Serdar" wrote:
> On Tue, Mar 6, 2018 at 2:58 PM, Bharath Ram
> wrote:
> > In that case, for a nested struct from top to bottom, all the values are
> > copies as values, correct? i.e, string, int, float, array etc will be
> copied
> > by value & map,
In that case, for a nested struct from top to bottom, all the values are
copies as values, correct? i.e, string, int, float, array etc will be
copied by value & map, slice, channel etc will be copied as pointers if
they are initialized?
https://play.golang.org/p/NzH8LVyQ0rp code works as I wan
On Wednesday, 7 March 2018 07:39:56 UTC+11, andrey mirtchovski wrote:
>
> maybe this will give you a hint: https://play.golang.org/p/ANIjc3tCdwp
>
> maps are reference types, but they still get passed by value.
>
Maps are pointers, pointers are values.
--
You received this message because yo
On Tue, Mar 6, 2018 at 1:23 PM, wrote:
> go version 1.10
>
>
> Operating system and processor architecture
>
> GOHOSTARCH="amd64"
> GOHOSTOS="darwin"
> However, this happens in play.golang.org env as well.
>
>
> Checkout the code.
>
> https://play.golang.org/p/v6u7R_nbGRp
doc1 := Document{}
//
maybe this will give you a hint: https://play.golang.org/p/ANIjc3tCdwp
maps are reference types, but they still get passed by value. if you
pass a nil map around, the old value you passed will not magically
start pointing to a new map once you instantiate it elsewhere.
--
You received this messa
go version 1.10
Operating system and processor architecture
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
However, this happens in play.golang.org env as well.
Checkout the code.
https://play.golang.org/p/v6u7R_nbGRp
In the example, if the struct (Document) is not initialized at first, there
is no pl