go
10 commands
10 shown
Build binary for Linux
Cross-compile a Go binary for Linux/amd64
GOOS=linux GOARCH=amd64 go build -o bin/app ./cmd/app
Run tests with race detector
Run all tests with race condition detection enabled
go test -race -count=1 ./...
Show test coverage
Generate HTML coverage report and open in browser
go test -coverprofile=cov.out ./... && go tool cover -html=cov.out
Add a dependency
Download a specific module version and update go.mod
go get github.com/some/pkg@v1.2.3
Tidy up module dependencies
Add missing and remove unused module dependencies
go mod tidy
Vendor dependencies
Copy all module dependencies into the vendor/ directory
go mod vendor
CPU profiling
Run benchmarks, collect CPU profile, open pprof interactive UI
go test -cpuprofile=cpu.prof -bench=. ./... && go tool pprof cpu.prof
List all packages
Print import paths of all packages in the module
go list ./...
Format all code
Reformat all .go files in the current tree
gofmt -w .
Static analysis with vet
Report likely mistakes in Go source code
go vet ./...
no commands match