package main import "fmt" type Counter struct{ n int } // value receiver: operates on a copy func (c Counter) Inc() { c.n++ } func main() { c := Counter{} c.Inc() fmt.Println(c.n) // 0, unchanged }
it cannot mutate the original