-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Mastering Go
By :

Go has support for pointers but not for pointer arithmetic, which is the cause of many bugs and errors in programming languages like C. A pointer is the memory address of a variable. You need to dereference a pointer in order to get its value—dereferencing is performed using the *
character in front of the pointer variable. Additionally, you can get the memory address of a normal variable using an &
in front of it.
The next diagram shows the difference between a pointer to an int
and an int
variable.
Figure 2.4: An int variable and a pointer to an int
If a pointer variable points to an existing regular variable, then any changes you make to the stored value using the pointer variable will modify the regular variable.
The format and the values of memory addresses might be different between different machines, different operating systems, and different architectures.
You might ask, what is the point of using pointers when there...