package main
import "fmt"
func local() {
var x *int = 1
fmt.Println("local var is", x)
}
&x = 13
func main() {
local()
fmt.Println(x)
}
Why would you want to do that? Breaking scope seems like a horrible idea.
First of all you're not even using correct syntax
Second of all if you're declaring it at the class level you don't need to deal with pointerspackage main
import (
"fmt"
)
var x int
func local() {
x = 4
fmt.Println(x)
}
func main() {
local()
}
And if you want pointerspackage main
import (
"fmt"
)
func local(x *int) {
*x = 4
fmt.Println(*x)
}
func main() {
x := 0
local(&x)
}
>>61773668
>>61773707
Fuckin hell man. I will never be a programmer.