contains another variable's memory address. 「 Trying to make you to fall in love with Golang 」 1 / 9 Pointers in Go Luca Sepe Software Craftsman, Solution Architect, Trainer https://twitter.com/lucasepe/ https://github.com/lucasepe/ https://lucasepe.it/
that holds information. This "tagged box" in memory has a specific address, represented by a unique number The picture on the right shows a variable "tagged" foo wich contains the value 10 and is located at 0xc00002c008 . 「Trying to make you to fall in love with Golang」 - Pointers 2 / 9 Pointers in Go Luca Sepe Software Craftsman, Solution Architect, Trainer https://twitter.com/lucasepe/ https://github.com/lucasepe/ https://lucasepe.it/
contains another variable's memory address. Writing bar := &foo we are defining a pointer to the foo variable. bar is a pointer - it points to the memory address of foo &foo gives the address of the variable ("box") whose "tag" is foo 「Trying to make you to fall in love with Golang」 - Pointers 3 / 9 Pointers in Go Luca Sepe Software Craftsman, Solution Architect, Trainer https://twitter.com/lucasepe/ https://github.com/lucasepe/ https://lucasepe.it/
by bar we need to "follow that pointer" that is "dereferencing" or "indirecting" that pointer *bar gets the value stored at the address pointed by bar *bar = XXX updates the value stored at the address pointed by bar 「Trying to make you to fall in love with Golang」 - Pointers 5 / 9 Pointers in Go Luca Sepe Software Craftsman, Solution Architect, Trainer https://twitter.com/lucasepe/ https://github.com/lucasepe/ https://lucasepe.it/
pointer, we should use *g dereferencing syntax, like this (*g).Title , to get the struct field value. But Go allows us to access the fields of a struct pointer without dereferencing it, using the simplest syntax g.Title Go will take care of dereferencing a pointer under the hood Try It! 6 / 9 Pointers in Go Luca Sepe Software Craftsman, Solution Architect, Trainer https://twitter.com/lucasepe/ https://github.com/lucasepe/ https://lucasepe.it/
create a pointer. allocates enough memory to accommodate a value of that type returns a pointer to it Try it! 「Trying to make you to fall in love with Golang」 - Pointers 7 / 9 Pointers in Go Luca Sepe Software Craftsman, Solution Architect, Trainer https://twitter.com/lucasepe/ https://github.com/lucasepe/ https://lucasepe.it/
language supporting garbage collection, so return the address of a local variable is absolutely safe. Try It! 「Trying to make you to fall in love with Golang」 - Pointers 8 / 9 Pointers in Go Luca Sepe Software Craftsman, Solution Architect, Trainer https://twitter.com/lucasepe/ https://github.com/lucasepe/ https://lucasepe.it/
(@night) {twitter.com, github.com, linkedin.com} / lucasepe 「Trying to make you to fall in love with Golang」 - Pointers 9 / 9 Pointers in Go Luca Sepe Software Craftsman, Solution Architect, Trainer https://twitter.com/lucasepe/ https://github.com/lucasepe/ https://lucasepe.it/