Numbers passed by reference



examples/function-increment-with-pointer/function_increment_with_pointer.go
package main

import "fmt"

func main() {
    a := 1
    fmt.Printf("before %v\n", a)
    inc(&a)
    fmt.Printf("after %v\n", a)
}

func inc(val *int) {
    fmt.Printf("address of val in inc: %v\n", val)
    fmt.Printf("val in inc: %v\n", *val)
    *val++
    fmt.Printf("val in inc: %v\n", *val)
}

before 1
address of val in inc: 0xc0000140e0
val in inc: 1
val in inc: 2
after 2