To retrieve a value from a pointer to an int in Go, you need to use the dereferencing operator *.
Here's an example:
main.go213 chars16 linesIn this example, we initialize a pointer to an int ptrToInt and an int value intValue. We then assign the address of intValue to ptrToInt using the address-of operator &.
To retrieve the value stored in ptrToInt, we use the dereferencing operator * in the fmt.Println statement which produces the following output:
main.go57 chars3 lines
So the output shows the actual memory address of the intValue variable and the value stored in it, respectively.
gistlibby LogSnag