Programming Code Center(PCC)
[GO]

(PCC)::[How-pointers-work-in-contrast-to-values-with-2-functions-zeroval-and-zeroptr-in-go-language]::[go]

File Name : pointers.go

package main

import "fmt"

func zeroval(ival int) {
    ival = 0
}

func zeroptr(iptr *int) {
    *iptr = 0
}

func main() {
    i := 1
    fmt.Println("initial:", i)

    zeroval(i)
    fmt.Println("zeroval:", i)

    zeroptr(&i)
    fmt.Println("zeroptr:", i)

    fmt.Println("pointer:", &i)
}

Output :

pointers.jpg