Saving pointers work
parent
3686956a02
commit
27d4857f3c
@ -0,0 +1,4 @@
|
||||
# Pointers and Errors
|
||||
|
||||
https://quii.gitbook.io/learn-go-with-tests/go-fundamentals/pointers-and-errors
|
||||
|
@ -0,0 +1,3 @@
|
||||
module pointers_errors
|
||||
|
||||
go 1.21.0
|
@ -0,0 +1,12 @@
|
||||
package pointers_errors
|
||||
|
||||
type Wallet struct {
|
||||
balance int
|
||||
}
|
||||
|
||||
func (w Wallet) Deposit(amount int) {
|
||||
}
|
||||
|
||||
func (w Wallet) Balance() int {
|
||||
return 0
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package pointers_errors
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestWallet(t *testing.T) {
|
||||
|
||||
wallet := Wallet{}
|
||||
|
||||
wallet.Deposit(10)
|
||||
|
||||
got := wallet.Balance()
|
||||
want := 10
|
||||
|
||||
if got != want {
|
||||
t.Errorf("got %d want %d", got, want)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue