learn-go-with-tests/pointererror/pointererror.go
2025-02-01 21:18:14 -05:00

22 lines
360 B
Go

package pointererror
import "fmt"
type Bitcoin int
func (b Bitcoin) String() string {
return fmt.Sprintf("%d BTC", b)
}
type Wallet struct {
balance Bitcoin
}
func (w *Wallet) Deposit(amount Bitcoin) {
w.balance += amount * 2
}
func (w *Wallet) Balance() Bitcoin {
fmt.Printf("address of balance in Balance is %p \n", &w.balance)
return w.balance
}