The Go toolchain is intentionally small: one compiler, formatter, test runner, and module-aware dependency manager—all invoked through the go command.
Essential commands
go run .— compile and run package in current directorygo build— produce an executable binarygo test ./...— run tests in modulego fmt ./...— format code to standard stylego mod init/go get— modules and dependencies
Modules and GOPATH (preview)
Modern Go uses modules (go.mod) for dependency versions. Legacy GOPATH workspace layout is rarely needed for new projects—modules are the default since Go 1.16+.
Important interview questions and answers
- Q: What is go.mod?
A: The module definition file listing module path and Go version;go.sumrecords checksums of dependencies. - Q: Why is go fmt important?
A: Enforces consistent formatting across teams—no style debates; CI often runsgo fmtchecks.
Self-check
- Which command runs tests in a module?
- What file declares your module path?
Tip: One go command runs fmt, test, build, and mod—run go fmt ./... before every commit like rustfmt in the Rust track.
Interview prep
- What is go.mod?
The module definition file listing module path, Go version, and dependencies; go.sum records checksums for reproducible builds.
- Essential go commands?
go run,go build,go test,go fmt,go mod tidy.