Essential Go Basic types  Suggest an edit

Pointers

A pointer to a type is the address of the value of that type in memory.

Zero value of a pointer is nil.

Unlike C, Go doesn’t have pointer arithmetic. You can take an address of a variable but you can’t add or substract from a pointer.

Pointer basics

var a int = 4
pa := &a
fmt.Printf("Address of a variable in memory is %p. Its value is: %d\n", pa, *pa)
Address of a variable in memory is 0xc0000180a0. Its value is: 4

Learn more about pointers.

  ↑ ↓ to navigate     ↵ to select     Esc to close