From 4a497b9f9347ad3e4b380270c69225279944a1f5 Mon Sep 17 00:00:00 2001 From: vinchent Date: Wed, 11 Sep 2024 11:49:10 +0200 Subject: [PATCH] wallet: add example --- wallet/wallet_test.go | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/wallet/wallet_test.go b/wallet/wallet_test.go index 5c1e012..77f6c97 100644 --- a/wallet/wallet_test.go +++ b/wallet/wallet_test.go @@ -1,6 +1,25 @@ package wallet -import "testing" +import ( + "fmt" + "testing" +) + +func ExampleWallet() { + wallet := Wallet{10} + + wallet.Deposit(10) + fmt.Printf("The balance is %s\n", wallet.Balance()) + + err := wallet.Withdraw(10) + if err != nil { + fmt.Println(err) + } + fmt.Printf("The balance is %s\n", wallet.Balance()) + + // Output: The balance is 20 BTC + // The balance is 10 BTC +} func TestWallet(t *testing.T) { t.Run("deposit", func(t *testing.T) {