Stage 1 · Code
Getting Started
Installing Go
Install the official Go toolchain, verify it from the terminal, and understand the environment variables and folders Go uses in practice.
Why the Official Toolchain
The official Go release includes the compiler, linker, formatter, package manager, documentation tooling, and standard library. That matters because beginners need one stable toolchain with predictable behaviour, not a pile of packages that each behave differently.
If the compiler is installed correctly, the rest of the course becomes much easier. Installation problems should be solved at the start, not discovered halfway through your first project.
Install by Platform
| Platform | Recommended path | Notes |
|---|---|---|
| macOS | Official .pkg or Homebrew | The official package is simplest for new learners |
| Windows | Official MSI installer | Open a new terminal after installation so PATH refreshes |
| Linux | Official tarball or distro package | Use the official tarball if your distro ships an old release |
# Download the current release from go.dev/dl
sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf go1.22.5.linux-amd64.tar.gz
# Add Go to PATH for the current shell
export PATH="$PATH:/usr/local/go/bin"The tarball approach is deterministic and easy to document. The PATH line is temporary unless you add it to your shell profile.
Verify the Install
Verification is not a formality. It confirms that your shell can find go, that Go can print its own configuration, and that your environment is ready for the next lesson.
go version
go env GOROOT GOPATH GOMODCACHE
go env PATHgo version confirms the release. go env reveals where Go stores the compiler, cache, and module downloads.
If go version fails with command not found, your shell does not know where the Go binary lives. The most common cause is an outdated PATH in an already-open terminal window.
How Go Finds Tools
terminal command
↓
shell searches PATH
↓
finds go executable
↓
go reads GOROOT, GOPATH, GOMODCACHE
↓
toolchain compiles or runs your programUnderstanding lookup order helps you debug setup problems quickly. Most installation issues are really PATH issues.
| Variable | Role | Do you edit it often? |
|---|---|---|
| GOROOT | Where Go itself is installed | No |
| GOPATH | Workspace and tool install location | Rarely |
| GOMODCACHE | Downloaded module cache | No |
| PATH | Folders searched for executables | Sometimes, when tools are not found |
Common Install Errors
gonot found: PATH does not include the Go binary directory.- Old version shows up: you have another Go install earlier in PATH.
- Permissions error on Linux: the extracted files were not placed under a writable location or were unpacked with the wrong privileges.
- Homebrew install succeeded but shell still cannot find
go: open a new terminal or reload your shell profile.
If you install Go via the official package, then later install another copy with Homebrew or a package manager, you can create path conflicts that are confusing to debug.
Case Study
In production engineering, installation scripts often fail not because the software is complex, but because environments differ. A good team writes installation instructions that are repeatable, explicit, and easy to validate. That is why many engineering organizations distribute a single versioned Go toolchain to all engineers and build agents.
- CI agents use the same Go version as developer laptops to avoid surprise build failures.
- Binaries are built from a known toolchain so bugs are easier to reproduce.
- Version pinning reduces drift between local testing and deployment pipelines.
Interview Preparation
- What is the difference between GOROOT, GOPATH, and PATH?
- Why is a new terminal window sometimes needed after installation?
- Why do teams prefer a consistent toolchain version across developers and CI?
- How would you diagnose a
go: command not founderror?
STAR sample answer: On a previous team, builds failed intermittently because different developers had different Go versions installed. I standardized the toolchain version in the setup docs and added a go version check to onboarding. The result was fewer environment-related failures and faster onboarding. The trade-off was a stricter version policy, but the stability gain was worth it.
Quiz and Practice
- Which site should you trust for Go installers? A) random blog B) go.dev/dl C) package README D) forum post. Answer: B.
- What does PATH do? A) stores source files B) lists folders searched for commands C) compiles packages D) formats code. Answer: B.
- What command confirms the installed version? A) go env B) go version C) go build D) go list. Answer: B.
- Why open a new terminal after installation? A) faster compiler B) to refresh PATH C) to update modules D) to clear cache. Answer: B.
- What should you do if multiple Go versions are installed? A) ignore them B) add more versions C) understand PATH order and remove the conflict D) rename the executable. Answer: C.
Short coding task: run go version, save the output, then run go env GOROOT GOPATH GOMODCACHE. Write one sentence describing what each value represents.
Hands-On Project
Write a short onboarding note for your own machine that explains how you installed Go, how you verified it, and what you would check if the next developer on your team reported a broken install.
- Record the Go version you installed.
- Paste the verification commands and their output.
- Write a troubleshooting section for
go not foundand version conflicts. - Store the note in a text file so you can reuse it later.
The project is complete when another engineer could use your note to verify Go on their own machine without asking you for clarification.
Summary and Key Takeaways
- Use the official Go toolchain when possible.
- Verify the install in a fresh terminal, not the one you used before installation.
- GOROOT, GOPATH, GOMODCACHE, and PATH serve different purposes.
- Most installation problems are path or version conflicts, not deep toolchain bugs.
- Good setup notes turn one-time knowledge into reusable team infrastructure.
This lesson prepares you for the next step in the course: writing and running your first Go program. The habit to keep is simple and durable — verify the environment before blaming the code.
Mark this lesson complete to store local progress and unlock a cleaner resume path the next time you visit.