Go Commands
Compiled language and toolchain from Google.All Go pages
- go mod init: create a Go module (go.mod)go mod init MODULE_PATH creates go.mod in the current directory and starts a Go module. How to choose the module path, then add dependencies with go mod tidy.
- go mod tidy: add missing and remove unused Go module dependenciesgo mod tidy adds missing module requirements, removes unused ones and updates go.sum. Flags such as -diff, -v and -go, how it treats build tags, and CI checks.
- go test -run TestName: run a single Go testRun one Go test with go test -run '^TestName$': how the regular expression matches tests and subtests, -skip, -count=1 to bypass the cache, and common mistakes.
- GOOS=linux GOARCH=amd64 go build: cross-compile Go binariesSet GOOS and GOARCH to build Go binaries for another OS or CPU, with no extra toolchain. Targets, PowerShell syntax, CGO_ENABLED=0 and smaller static binaries.