package pointers import ( "fmt" "errors" ) type Bitcoin int type Stringer interface { String() string } func (b Bitcoin) String() string { return fmt.Sprintf("%d BTC", b) } type Wallet struct { // when using lowercase properties names, it will be private balance Bitcoin } func (w *Wallet) Deposit(amount Bitcoin) { w.balance += amount } func (w *Wallet) Balance() Bitcoin { return w.balance } func (w *Wallet) Withdraw(amount Bitcoin) error { if amount > w.balance { return errors.New("cannot withdraw, insufficient funds") } w.balance -= amount return nil }