Go Cheat Sheet
Practical Go cheat sheet with setup steps, core workflows, debugging, and copy-paste examples.
go syntax examples reference
Go cheat sheet with real commands and snippets for setup, core workflows, debugging, and production-safe automation patterns. If you are working across tools, pair this with the Elixir Cheat Sheet and HTML Cheat Sheet.
Setup and Tooling
Goal: Install and verify language toolchain
# Run go command
go version
# Run go command
go mod init example.com/app
# Run go command
go env GOPATH
Core Workflows
Goal: Run and build source code
# Execute go workflow
go run ./cmd/app
# Execute go workflow
go build ./...
Goal: Use a practical code snippet
package main
import "fmt"
func main() {
values := []int{1, 2, 3}
for _, v := range values {
fmt.Println(v)
}
}
Testing and Formatting
Goal: Run automated tests
# Execute test-related command
go test ./...
# Execute test-related command
go test ./... -cover
Goal: Run lint and formatter checks
# Execute quality command
gofmt -w .
# Execute quality command
go vet ./...
Automation and CI
Goal: Create a repeatable CI shell step
# Run strict shell mode for CI step
set -euo pipefail
# Install dependencies deterministically
npm ci || pip install -r requirements.txt || true
# Run tests and fail fast on errors
go test ./...
Debugging and Troubleshooting
Goal: Trace runtime issues
# Print runtime and package manager versions
node --version || python --version || true
# Search stack traces and TODO markers
rg "Traceback|Exception|TODO" .
# Re-run tests with verbose output
go test ./... -v || go test ./... --verbose || true
Common Gotchas
- Pin Go language/runtime versions in local and CI environments.
- Keep formatting and linting automated to avoid noisy diffs in code review.
- Prefer explicit dependency lock files for reproducible builds.
- Write small, deterministic tests that can run quickly in pre-commit checks.
- Document compiler/interpreter flags used in production builds.
Related Sheets
- Elixir Cheat Sheet — daily Elixir commands and production-ready examples.
- HTML Cheat Sheet — daily HTML commands and production-ready examples.
- Java Cheat Sheet — daily Java commands and production-ready examples.
Related Cheat Sheets
HTML Cheat Sheet
Practical HTML cheat sheet with setup steps, core workflows, debugging, and copy-paste examples.
Elixir Cheat Sheet
Practical Elixir cheat sheet with setup steps, core workflows, debugging, and copy-paste examples.
Java Cheat Sheet
Practical Java cheat sheet with setup steps, core workflows, debugging, and copy-paste examples.