-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
32ace4e
commit 1e6ef54
Showing
3 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
date: 2021-07-18T16:07:39-05:00 | ||
title: Go R1 Day 54 | ||
slug: go-r1-day-54 | ||
area: go | ||
round: 1 | ||
day_counter: 54 | ||
tags: | ||
- tech | ||
- development | ||
- 100DaysOfCode | ||
- golang | ||
- microblog | ||
typora-root-url: ../../../static | ||
typora-copy-images-to: ../../../static/images | ||
|
||
# images: [/images/r1-d54-IMAGE.png] | ||
|
||
--- | ||
|
||
## progress | ||
|
||
- worked with tests and Goland. | ||
- Modified table driven tests to remove hard coded test case inputs. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
--- | ||
date: 2021-07-19T16:07:41-05:00 | ||
title: Go R1 Day 55 | ||
slug: go-r1-day-55 | ||
area: go | ||
round: 1 | ||
day_counter: 55 | ||
tags: | ||
- tech | ||
- development | ||
- 100DaysOfCode | ||
- golang | ||
- microblog | ||
typora-root-url: ../../../static | ||
typora-copy-images-to: ../../../static/images | ||
images: [/images/go-r1-d55-goland-test-summary.png] | ||
|
||
--- | ||
|
||
## progress | ||
|
||
> In Go, when you call a function or a method the arguments are copied. [^pointers] | ||
- Built some test cases for working with pointers and test methods. | ||
- Did this in Goland to become more familar with it and figured out how to use the nice tests explorer with a floating window to auto-test. | ||
- Built a filewatcher configuration watcher as alternative to tests panel, allowing automated run in terminal or output panel of `go test ./...`. | ||
- Couldn't figure out how to run every test in project, as it's a multi-module repo (for tutorials). | ||
VSCode works fine with this with the multi-module support. | ||
|
||
> These pointers to structs even have their own name: struct pointers and they are automatically dereferenced. [^pointers] | ||
This explains something that felt a little confusing as a new Gopher. | ||
Now I know why returning a value back as an int didn't require explicit dereferencing. [^dereferencing] | ||
|
||
```go | ||
func (w *Wallet) Balance() int { | ||
return w.balance // <---- automatically deferenced | ||
} | ||
``` | ||
|
||
Not clear yet on if I need to set the `is := New(t)` in the context of each `t.Run()` or not. | ||
|
||
```go | ||
t.Run("withdraw 2 amounts", func(t *testing.T) { | ||
wallet := pointers.Wallet{} | ||
wallet.Deposit(pointers.Bitcoin(20)) | ||
err := wallet.Withdraw(pointers.Bitcoin(5)) | ||
is.NoErr(err) // Withdraw should have no errors | ||
assertBalance(t, &wallet, pointers.Bitcoin(15)) | ||
}) | ||
``` | ||
|
||
## links | ||
|
||
- [feat: ✅ add pointer test progress · sheldonhull/learn-go-with-tests-applied@f89a206 · GitHub](https://github.com/sheldonhull/learn-go-with-tests-applied/commit/f89a2069def3c99c6a0199b64b826034e8b37edc) | ||
- [tests: 🧪 refactor tests for bitcoin wallet and run configurations · sheldonhull/learn-go-with-tests-applied@9f27fe0 · GitHub](https://github.com/sheldonhull/learn-go-with-tests-applied/commit/9f27fe07a8437de7182698c820733b4d57c1be28) | ||
- [tests: 🧪 refactor tests for bitcoin wallet and improve final test cov… · sheldonhull/learn-go-with-tests-applied@1f3db9f · GitHub](https://github.com/sheldonhull/learn-go-with-tests-applied/commit/1f3db9f57ee622f90f5de50c01073891c4457d92) | ||
|
||
[^pointers]: [Pointers](https://quii.gitbook.io/learn-go-with-tests/go-fundamentals/pointers-and-errors) | ||
[^dereferencing]: [Method Values](https://golang.org/ref/spec#Method_values) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.