package main import "fmt" // a *int lets the function change the caller's variable func double(n *int) { *n *= 2 } func main() { x := 5 double(&x) fmt.Println(x) // 10 }
pass an address to change a value