Go
Go toolchain commands for building, testing, and managing modules. Format code, run benchmarks, and handle dependencies.
69 commands
Browse by Topic
Getting Started
Quick setup and installation
Build
Compilation & cross-compilation
Modules
Module management
Test
Testing & benchmarks
Quality
Vet, fmt, lint
Environment
Environment variables
Workspaces
Multi-module workspaces
Install
Installing tools
Run
Running & docs
Install Go (macOS)
Install Go using Homebrew on macOS
Check Go version
Display installed Go version
Initialize Go module
Initialize a new Go module in the current directory
Build project
Compile packages and dependencies in current directory.
Build with output name
Compile and specify output binary name.
Build with verbose
Verbose output showing compiled packages.
Build for Linux
Cross-compile for Linux AMD64.
Build for Windows
Cross-compile for Windows AMD64.
Build for macOS ARM
Cross-compile for Apple Silicon.
Build with race detector
Enable data race detection (slower but safer).
Build stripped binary
Strip debug info for smaller binary size.
Build with version info
Inject version at build time via ldflags.
Build with trimpath
Remove file system paths from binary for reproducibility.
Production build
Static binary with no CGO, stripped debug info.
Build with tags
Include files with matching build tags.
Initialize module
Create new Go module (generates go.mod).
Tidy dependencies
Add missing and remove unused dependencies.
Download dependencies
Download modules to local cache.
Vendor dependencies
Copy dependencies to vendor directory.
Verify dependencies
Verify dependencies match go.sum checksums.
Show dependency graph
Print module dependency graph.
Explain why needed
Explain why a package/module is needed.
Add dependency
Add package to module dependencies.
Add specific version
Add package at specific version.
Update all dependencies
Update all dependencies to latest minor/patch.
Edit go.mod (replace)
Add module replacement for local development.
List all modules
List all module dependencies.
Run all tests
Run tests in all packages recursively.
Run with verbose
Verbose output showing all test names.
Run specific test
Run only tests matching pattern.
Run with coverage
Display coverage percentage.
Generate coverage report
Generate coverage profile file.
View coverage in browser
Open coverage report in browser.
Run with race detector
Enable race detection during tests.
Disable test caching
Force re-run tests (bypass cache).
Set test timeout
Set maximum test duration.
Run benchmarks
Run all benchmarks.
Benchmarks with memory
Show memory allocation statistics.
Fuzz testing
Run fuzzing on specific test for 30 seconds.
CPU profiling
Generate CPU profile during benchmarks.
Static analysis
Examine code for suspicious constructs.
Format code
Format all Go files recursively.
Simplify code
Format and simplify code patterns.
Run go fix
Update code to use new APIs after Go upgrade.
Run golangci-lint
Run comprehensive meta-linter.
Lint with auto-fix
Auto-fix linting issues where possible.
Run go generate
Run code generators specified in //go:generate.
Show all env vars
Display all Go environment variables.
Get specific env var
Show specific environment variable.
Set env var persistently
Set Go environment variable permanently.
Set private modules
Configure private modules (bypass proxy).
Disable CGO
Build without C bindings for static binary.
Output as JSON
Show environment as JSON.
Initialize workspace
Create go.work file for multi-module development.
Add module to workspace
Add module directory to workspace.
Add all modules recursively
Add all Go modules in subdirectories.
Sync workspace
Sync workspace dependencies to all modules.
Edit workspace
Add replacement to workspace.
Install tool (latest)
Install Go tool at latest version.
Install specific version
Install tool at specific version.
Install from local
Install current package as executable.
List installed
List installed Go binaries.
Run file
Compile and run single file.
Run package
Compile and run current package.
Run with race detector
Run with data race detection enabled.
View package docs
Show documentation for package.
View function docs
Show documentation for specific symbol.
Clean build cache
Clear build cache.
Clean module cache
Clear module download cache.
Discussion
Loading comments...