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:
go get -u ./... && go mod tidy