learn-go-with-tests/pointererror/pointererror.go

23 lines
360 B
Go
Raw Permalink Normal View History

2025-02-02 02:18:14 +00:00
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
}