Golang pointers
16 August 2024 (Updated 16 August 2024)
What is a pointer?
A pointer is a special variable that holds the memory address of another variable.
Initialise a pointer
myPointer
is initialised to the zero value of nil
.
Access memory address of a variable
Generate a pointer to a variable
myPointer
holds the memory address of myInt
.
Get a pointer’s value (dereference)
This reads the value at the pointer myPointer
Tagged:
Golang