The `go` command is Go’s command-line toolchain. It compiles and runs packages, but also brings package management, formatting, testing, and documentation into the same development workflow. section 1.1 section 6.0
Use its commands as the task changes:
- Manage modules and dependencies with `go mod` and `go get ./...`; use `go fmt` to keep code formatting consistent. section 1.2.4
- Run unit tests with `go test`, then use `go test -cover` to measure statement coverage. section 1.2.4
- Use the toolchain’s documentation and code-checking capabilities alongside building and testing; `vet` is among the available tools. section 1.2.4 section 6.0
Test a change before shipping it
A name-reversal test fails under `go test`. Changing the reversal to work with runes rather than bytes makes the test pass; `go test -cover` then reports how many statements the tests exercised. The failure, fix, and coverage result are separate checks: passing tests do not imply comprehensive coverage. section 1.2.4
For a binary targeting another platform, set `GOOS` and `GOARCH` when building. Test the result on its target platform, especially if the application uses cgo; cross-compilation can introduce complications with C libraries. section 12.4.2
$ GOOS=windows GOARCH=386 go build
This command builds a Windows binary for the 386 architecture by setting the target operating system and architecture for `go build`. section 12.4.2

