// Created on savesnippets.com · https://savesnippets.com/a0r7xQlJ5eNbEm package main import "fmt" type Point struct { X, Y int } // Value receiver — caller\'s copy is unchanged func (p Point) ScaleVal(n int) { p.X *= n p.Y *= n } // Pointer receiver — caller\'s value IS mutated func (p *Point) ScalePtr(n int) { p.X *= n p.Y *= n } func main() { p := Point{X: 1, Y: 2} p.ScaleVal(10) fmt.Println(p) // {1 2} — unchanged p.ScalePtr(10) // Go auto-addresses: &p fmt.Println(p) // {10 20} // & to take address, * to dereference n := 5 ptr := &n *ptr = 99 fmt.Println(n) // 99 // Distinguish "no value" with a pointer var opt *Point // nil — meaning "absent" if opt == nil { fmt.Println("no point") } }