go doc
- Display doc for current package:
go doc
- Display doc for type in current package:
go doc TYPE
orgo doc -all TYPE
go test
Run all tests:
- Run all tests:
go test ./...
- Run all tests in package:
go test modulename/pkg/packagename/
- Run all tests in file:
go test path/to/file_test.go
Run subset of tests:
- Run function tests:
go test path/to/file_test.go -run FUNCTION_TEST_NAME
- Run a single test in function tests:
go test path/to/file_test.go -run FUNCTION_TEST_NAME/test_name_here
Tips:
- Skip test caching with
-count 1
. - Run tests multiple times with
-count 10
. Useful for finding flaky tests. - Add
-v
for verbose output. Useful for finding test names and whatnot.
go get
Upgrade all dependencies:
docker run -it -v .:/app -w /app golang:DESIRED_GO_VERSION sh # optional
go list -m -u all | awk '{print $1}' | xargs -n 1 go get -u
go mod tidy