wallet: implement stringer interface
This commit is contained in:
parent
71bc024fe2
commit
36ef78fb92
@ -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
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user