wallet: implement stringer interface
This commit is contained in:
		@ -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)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user