Pointers

suggest change

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

main.go

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

Output:

Address of a variable in memory is 0xc00007e010. Its value is: 4

Learn more about pointers.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents