Pointers to struct
Struct fields can be accessed through a struct pointer.
To access the field X
of a struct when we have the struct pointer p
we could write (*p).X
. However, that notation is cumbersome, so the language permits us instead to write just p.X
, without the explicit dereference.
That is called automatic dereference
pointer-methods-in-go
References
#golang #reference #pointer #value #pass_by #stack #programming #heap #for_the_love_of_go