Today i was reviewing some code and i found the following behavior:
func main(){
a := testing()
fmt.Println(*a)
}
func testing() *int{
i := 7
return &i
}
https://go.dev/play/p/Peubn0degBr
OUTPUT: 7
My question is: what is happening here? var i only exists on the scope of testing(). But somehow go lang saves the pointer and understands that it needs that value.