How pointer & and * and ** works in Golang?

The below program is curry of pointers. The value of intVar is equals to value of **pointerToPointerVar.
package main
import "fmt"
func main() {
    var intVar int
    var pointerVar *int
    var pointerToPointerVar **int
    intVar = 100
    pointerVar = &intVar
    pointerToPointerVar = &pointerVar
	fmt.Println("\n")
    fmt.Println("intVar:\t\t\t", intVar)
    fmt.Println("pointerVar:\t\t", pointerVar)
    fmt.Println("pointerToPointerVar:\t", pointerToPointerVar)
	fmt.Println("\n")
    fmt.Println("&intVar:\t\t", &intVar)
    fmt.Println("&pointerVar:\t\t", &pointerVar)
    fmt.Println("&pointerToPointerVar:\t", &pointerToPointerVar)
    fmt.Println("\n")
    fmt.Println("*pointerVar:\t\t", *pointerVar) 
    fmt.Println("*pointerToPointerVar:\t", *pointerToPointerVar)
    fmt.Println("**pointerToPointerVar:\t", **pointerToPointerVar)
}
C:\golang\codes>go run example.go


intVar: 100
pointerVar: 0x1142214c
pointerToPointerVar: 0x114240e0


&intVar: 0x1142214c
&pointerVar: 0x114240e0
&pointerToPointerVar: 0x114240e8


*pointerVar: 100
*pointerToPointerVar: 0x1142214c
**pointerToPointerVar: 100

C:\golang\codes>

Thanks for reading. Please leave your valuable feedback and comments.

* Required Fields

No questions yet. Be the first to ask the question!