https://github.com/slingercode/learn-go-with-tests
https://quii.gitbook.io/learn-go-with-tests
https://github.com/slingercode/learn-go-with-tests
Last synced: 4 days ago
JSON representation
https://quii.gitbook.io/learn-go-with-tests
- Host: GitHub
- URL: https://github.com/slingercode/learn-go-with-tests
- Owner: slingercode
- Created: 2024-03-28T16:14:04.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-03T05:54:56.000Z (about 2 years ago)
- Last Synced: 2025-11-17T07:09:29.871Z (7 months ago)
- Language: Go
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Learning go with tests
[Reference URL](https://quii.gitbook.io/learn-go-with-tests/go-fundamentals/iteration)
## Run tests
~~The package should be named as `SOMETHING_test`~~. Just ignore that
- `go test -v ./folder`
## Modules
- Hello world
- Integers
- Iteration
- Arrays and Slices
- Structs, methods and interfaces
## Quick Notes (bc i have short memory 🙃)
- `t.Helper()` is used in helper test functions so that if the test fails
the line number reported will be in our function call rather than inside
our test helper.
- `slices` package includes the `Equal` method already.
- `func x(numbers ...[]int)` is called a _Variadic Function_ and represents
a scenario when you can pass _n_ number of parameters of the same type
- `%#v` prints the struct values in a `printf` format
- In Go **interface resolution is implicit**. If the type you pass in
matches what the interface is asking for, it will compile.
- The structs can be defined with his properties names so that the reading
can be easier: `{shape: Rectangle{Width: 12, Height: 6}, want: 72.0}`