Javatpoint Logo
Javatpoint Logo

Go Pointer

A pointer is a variable that stores the address of another variable. The general form of a pointer variable declaration is:

A newly declared pointer which has not been assigned to a variable has the nil value.

The address-of operator &, when placed before a variable gives us the memory address of the variable.

With pointers, we can pass a reference to a variable (for example, as a parameter to a function), instead of passing a copy of the variable which can reduce memory usage and increase efficiency.

Go Pointer Example 1

Output:

x = 0

Go Pointer Example 2

Output:

Before change ptr 0
After change ptr 10 

Next TopicGo Reflect




Help Others, Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA