package main import "fmt" func swap(a, b *int) { *a, *b = *b, *a } func main() { x, y := 1, 2 swap(&x, &y) fmt.Println(x, y) // 2 1 }
exchange two values through *