Getting Started

Installation

Install Go on Windows, macOS, or Linux, verify it works, fix PATH problems, and set up your editor.

What you will learn

By the end of this lesson you will have a working Go installation that you have verified yourself, you will know what the installer put on your machine, and you will have an editor that formats your code and flags errors as you type.

What you are installing

Go is not just a compiler. The download is the Go toolchain: the go command (which builds, runs, tests, and manages dependencies), the compiler itself, the gofmt formatter, and the entire standard library. Everything you need is in one package, with no separate package manager or build tool to add.

Use the official installer from go.dev/dl unless you already manage tools with a package manager you trust. The current version number changes over time, so the download page is the source of truth.

Install Go

Pick the right download

Choose the package for your operating system and processor. If you are unsure of your processor:

  • Windows: open Settings → System → About. "x64-based processor" means amd64. Most PCs are this.
  • macOS: run uname -m in Terminal. arm64 means Apple silicon (M1 or later), and x86_64 means Intel.
  • Linux: run uname -m. x86_64 means amd64, and aarch64 means arm64.

Run the installer

Windows: run the .msi file and accept the defaults. The installer adds Go to your PATH automatically.

macOS: open the .pkg file and follow the wizard. Go is installed to /usr/local/go.

Linux: download the .tar.gz archive, then remove any old installation and extract the new one. Replace the filename with the one you downloaded:

sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf go1.x.x.linux-amd64.tar.gz

Linux does not update PATH for you. Add this line to ~/.profile (or ~/.zshrc if you use zsh):

export PATH=$PATH:/usr/local/go/bin

Open a new terminal

This step matters. Installers change your PATH, and a terminal that was already open will not see the change. Close it and open a new one. On Linux, either do the same or run source ~/.profile.

Verify the installation

Terminal
go version

You should see output like this:

go version go1.x.x windows/amd64

The version number and the operating system and processor will match your own machine. If you see this line, Go is installed.

Look at the environment

Go keeps its configuration in a set of environment settings. Print them all with:

Terminal
go env

That is a long list, so ask for two specific ones:

Terminal
go env GOROOT GOPATH
SettingWhat it isTypical value
GOROOTWhere the Go toolchain itself is installed/usr/local/go or C:\Program Files\Go
GOPATHA folder where Go stores downloaded modules, installed tools, and caches~/go or C:\Users\you\go

You rarely need to change either. Older Go tutorials told you to keep all your code inside GOPATH. That is no longer true. Today every project is a module, and it can live in any folder on your machine. You will create your first module in the next lesson, and GOPATH just quietly holds the files that Go downloads on your behalf.

Avoid setting GOROOT by hand. The installer already gets it right, and a wrong value causes confusing errors.

If go is not recognised

You might see go: command not found on macOS and Linux, or 'go' is not recognized as an internal or external command on Windows. That means your terminal cannot find the go program. Work through this order:

  1. Open a new terminal. This fixes most cases.
  2. Check where the terminal is looking.
SystemFind goShow PATH
Windows (PowerShell)Get-Command go$env:Path -split ';'
Windows (Command Prompt)where goecho %PATH%
macOS and Linuxwhich goecho $PATH
  1. Make sure Go's bin folder is in the list. It is usually C:\Program Files\Go\bin on Windows and /usr/local/go/bin on macOS and Linux. If it is missing, add it. On Windows use Settings → search "Environment Variables" → edit Path. On macOS and Linux add the export PATH=... line shown earlier to your shell profile.
  2. Reopen the terminal again after any change.

Essential commands

You will use these constantly, so it is worth skimming the list now.

CommandWhat it doesWhen you will use it
go versionPrints the installed versionChecking your setup
go run .Builds and runs the package in the current folderTrying your code
go build .Builds an executable and keeps itProducing a program to share
go test ./...Runs tests in every package below this folderChecking nothing broke
go fmt ./...Formats code in Go's standard styleBefore every commit
go mod tidySyncs go.mod with the imports in your codeAfter adding or removing imports
go doc fmt.PrintlnShows documentation in the terminalLooking up a function

Try go doc right now:

Terminal
go doc fmt.Println

It prints the function signature and description without opening a browser. Reading documentation this way is a habit that pays off all through the course.

Set up your editor

You can write Go in any text editor, because the Go toolchain does the real work. A good editor adds comfort: it formats on save, underlines compiler errors as you type, completes names, and jumps to definitions. These features come from a helper program called gopls, the official Go language server.

The easiest setup is VS Code:

  1. Install Visual Studio Code.
  2. Open the Extensions panel and install Go, published by the Go Team at Google.
  3. Open the Command Palette (Ctrl+Shift+P, or Cmd+Shift+P on macOS) and run Go: Install/Update Tools. Select everything, including gopls, and confirm.
  4. Open any .go file. On saving, the extension formats the file automatically.

GoLand, Neovim, and other editors work too. What matters is that they use gopls and gofmt, so you get the same experience.

Practice

  1. Run the command that shows your installed Go version.
  2. Print only your GOROOT and GOPATH.
  3. Imagine the terminal says go: command not found. Write the first three things you would check.

Summary

Install Go from the official download page, open a new terminal, and confirm it with go version. The installer provides the compiler, the formatter, and the standard library in one package. GOROOT is where Go lives and GOPATH is where it keeps downloaded files, and neither limits where your own projects go. If the go command is missing, the fix is almost always about PATH. An editor with gopls makes learning smoother, but the toolchain itself does the real work.

Official reference: Download and install Go.

Ready to wrap up?

Mark this complete when you can explain the main idea and finish the practice task.

Copyright © 2026