Pointers

  • Special types, variables which stores memory locations
  • var i *int32 = new(int32)
  • Use * to store a pointer
  • To deference a pointer (get the value stored at the memory address of the pointer): *i
  • To give it a value: *i = 10
  • If we want the memory address of a variable: &p
  • Useful when we want to find the memory location of an array to prevent making a copy of an array when modifying it (or any data)