Function semantics

Pointer parameters

A pointer parameter is itself copied. Dereferencing the pointer permits modification of its target; assigning a new pointer to the local parameter does not update the caller pointer. Check nil when it is a permitted input. Example output: '6'.

Formal Syntax & Structure

go syntaxgo
func change(p *T)

Working Example

Example Snippetgo
package main
import "fmt"
func change(p *int) { *p++ }func main() {  n := 5  change(&n)  fmt.Println(n)}
Go Reference