The go Command Overview

A short guide to the go command, what it does, and the four pages that explain its structure, build commands, module commands, and quality commands

Overview

The go command is the entry point for almost every development task in Go. It compiles code, fetches dependencies, runs tests, formats source files, and more, all without build scripts, makefiles, or complex configuration files.

The driving idea is that Go programs should compile using only the information already present in the code, the package declarations and the import blocks. If you follow a few basic rules, one package per directory and a go.mod file at the module root, the tool reads your source and figures out what to do.

A useful mental model is to think of the go command as a guide that already knows the layout of a Go project. You do not tell it where your code lives or how to link things. You write standard Go code, and the tool handles the rest.

Not a General Build Tool:

The go command is purpose-built for Go code. It cannot build C++ or Python projects, and it does not support custom build steps like makefiles do. That deliberate limitation is what keeps it simple and reliable.

What This Group Covers

The four pages under this heading each cover one part of the go command. Read them in order the first time through, then use any single page as a reference later.

Command Structure and Help

Every go invocation follows the shape go <command> [arguments]. This page explains that shape, the built-in help system, and how to get help for a subcommand or a concept such as modules or build constraints.

Core Build Commands

The four commands that turn source into something runnable, go build, go run, go install, and go clean. This page explains what each one produces, where the result lands, and which one fits a given job.

Package and Module Commands

The commands that manage dependencies and inspect code, go get, go list, go mod, and go work. This page explains how dependencies are added and upgraded, how to inspect packages and modules, and how workspaces let you develop several modules together.

Quality and Generation Commands

The commands that check and generate code, go test, go vet, go fmt, and go generate. This page explains how the four form a feedback loop that formats code, catches subtle mistakes, verifies behaviour, and automates repetitive code.

Command Structure and Help

Understanding the go command syntax, getting help, and navigating the built-in documentation system

Core Build Commands

An in-depth look at go build, go run, go install, and go clean, the essential commands that compile, execute, install, and clean Go code

Package and Module Commands

Detailed guide to managing Go dependencies, inspecting packages, maintaining modules, and using workspaces with go get, go list, go mod, and go work

Quality and Generation Commands

How go test, go vet, go fmt, and go generate work together to maintain code quality and automate repetitive code creation in Go projects