Essential Go Basic types  Edit on GitHub      File Issue


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

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 0xc420016090. Its value is: 4

Zero value of a pointer is nil.

Learn more about pointers.

  ↑ ↓ to navigate     ↵ to select     Esc to close