In computer RAM, we have cells and addresses. Cells are where values are stored and addresses are how values are accessed.
A pointer in Golang is a variable that is used to exclusively store the memory address of another variable. To make it short: "a pointer is a 'data item' that specifies the location of another 'data item'".
For instance, in the case of concurrency, pointers are used to share data like slices or maps between goroutines facilitating concurrent manipulation and access to those structures, notwithstanding the need for concurrent access to be synchronized to avoid race conditions.
Pointers in Go allow for the passing of references to variables rather than copies.
About pointer receivers and how methods work with pointers in Go
func (v *MyType)Method() {
...
}In Golang, a pointer receiver refers to a method that has a pointer type as its receiver.
This concept is paramount when we want to modify the value that the receiver points to,
or when we want to avoid copying the value on each method's call especially for large structs.
Unlike value receivers, pointer receivers allow methods to modify the original variable.
This is particularly useful when we need to change the state of a struct in a method.
Efficiency
ADTs can grow in size.
Using a pointer receiver avoids copying the entire data struct each time a method is invoked.