I Spy Code - GO

Pointer type

A pointer type denotes the set of all pointers to variables of a given type, called the base type of the pointer. The value of an uninitialized pointer is nil.

Here is a simple go lang example that shows how to use a pointers.

Source: (example.go)

package main
 
import "fmt"
 
func main() {
 
  // set a variable
  i := 100
  fmt.Println(i)
 
  // get the address of i
  p := &i
  fmt.Println(p)
 
  // print the contents of the address
  fmt.Println(*p)
 
}
 

Output:

$ go run example.go
100
0xc82000a2d8
100