wallet: implement stringer interface
This commit is contained in:
		@ -1,7 +1,13 @@
 | 
				
			|||||||
package wallet
 | 
					package wallet
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import "fmt"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type Bitcoin int
 | 
					type Bitcoin int
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (b Bitcoin) String() string {
 | 
				
			||||||
 | 
						return fmt.Sprintf("%d BTC", b)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type Wallet struct {
 | 
					type Wallet struct {
 | 
				
			||||||
	balance Bitcoin
 | 
						balance Bitcoin
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -11,6 +11,6 @@ func TestWallet(t *testing.T) {
 | 
				
			|||||||
	want := Bitcoin(10)
 | 
						want := Bitcoin(10)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if got != want {
 | 
						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