wallet: implement stringer interface

This commit is contained in:
vinchent 2024-09-11 11:17:23 +02:00
parent 71bc024fe2
commit 36ef78fb92
2 changed files with 7 additions and 1 deletions

View File

@ -1,7 +1,13 @@
package wallet
import "fmt"
type Bitcoin int
func (b Bitcoin) String() string {
return fmt.Sprintf("%d BTC", b)
}
type Wallet struct {
balance Bitcoin
}

View File

@ -11,6 +11,6 @@ func TestWallet(t *testing.T) {
want := Bitcoin(10)
if got != want {
t.Errorf("got %d want %d", got, want)
t.Errorf("got %q want %q", got, want)
}
}