package main import "fmt" type calc struct { value int } func (c calc) add(n int) calc { c.value = c.value + n return c } func (c calc) sub(n int) calc { c.value = c.value - n return c } func (c calc) mul(n int) calc { c.value = c.value * n return c } func (c calc) show() { fmt.Printf("Value: %d\n", c.value) } func main() { total := calc{} total = total.add(10) total.show() // Value: 10 total = total.mul(3) total.show() // Value: 30 total = total.sub(5) total.show() // Value: 25 }