How to Print the Memory Address of a Variable in Go
In this article, you’ll learn different ways to print the memory address of a variable in Go. This is useful when you want to find out the location in memory of a variable perhaps in order to compare it to something else when debugging your code.
The easiest way to print the memory address of a variable is to pass a pointer
to the variable to the fmt.Println()
method: