Function semantics
Pass-by-value semantics
Go copies each argument value into its parameter. Assigning a new value to the parameter cannot reassign the caller variable; copied pointers, slices and maps can still refer to shared data. Example output: '5'.
Formal Syntax & Structure
go syntaxgo
func change(n int)Working Example
Example Snippetgo
package main
import "fmt"
func change(n int) { n = 20 }func main() { n := 5 change(n) fmt.Println(n)}