LearnAI ToolsCareerPractice BuildsPlayContact
Lesson 517 min read

Installing Go

Install Go on Windows, macOS, or Linux, verify your installation, understand Go Modules, and set up VS Code for Go development.

Introduction

Before writing any Go code, you need the Go toolchain installed on your machine. The good news is that Go's installer is lightweight and the setup is simple on every major operating system — there are no complicated environment configurations required for modern versions of Go.

This lesson walks through installing Go on Windows, macOS, and Linux, verifying the install worked, understanding Go Modules (the modern replacement for the old GOPATH workflow), and configuring VS Code as your editor.

Downloading Go

The official source for Go installers is go.dev/dl. It provides pre-built packages for Windows, macOS, and Linux — always prefer this official source over third-party downloads.

Which Version Should I Install?

Always install the latest stable release listed on go.dev/dl unless a specific project requires an older version. Thanks to the Go 1 compatibility promise, newer Go versions remain backward compatible.

Installing on Windows

  • Go to go.dev/dl and download the Windows MSI installer (e.g. go1.22.windows-amd64.msi).
  • Run the downloaded .msi file and follow the installation wizard, keeping the default install location (C:\Program Files\Go).
  • The installer automatically adds Go to your system PATH.
  • Open a new PowerShell or Command Prompt window (important — existing windows won't see the updated PATH) and verify the install.

Installing on macOS

On macOS, you can either download the official .pkg installer from go.dev/dl, or install via Homebrew if you already use it.

# Option 1: Homebrew
brew install go
# Option 2: Download the official .pkg installer from go.dev/dl
# and run it like any standard macOS installer.

Installing on Linux

On Linux, download the tarball from go.dev/dl, extract it to /usr/local, and add Go's bin directory to your PATH.

# Remove any previous Go install, then extract the new one
sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf go1.22.linux-amd64.tar.gz
# Add Go to your PATH (add this line to ~/.bashrc or ~/.zshrc)
export PATH=$PATH:/usr/local/go/bin

After editing your shell profile, run `source ~/.bashrc` (or restart your terminal) so the PATH change takes effect.

Verifying Your Installation

On any operating system, once installed, verify Go is available by checking its version.

go version
Output

Click Run to see what this code prints.

You should see a version number and your platform (windows/amd64, darwin/arm64, linux/amd64, etc.). If you instead see "command not found" or "not recognized," Go's bin directory isn't on your PATH yet — double-check the steps above and open a fresh terminal window.

GOPATH vs Go Modules

Older Go tutorials mention GOPATH — a single workspace directory where all Go code used to have to live. Modern Go (1.16 and later) uses Go Modules by default, which let you create a project anywhere on disk. You do not need to configure GOPATH manually for day-to-day development; modules handle dependency management per-project via a `go.mod` file.

mkdir hello-go
cd hello-go
go mod init example.com/hello-go
Output

Click Run to see what this code prints.

This creates a `go.mod` file that marks the folder as a Go module and tracks its dependencies. You'll use `go mod init` at the start of every new project throughout this course.

Setting Up VS Code

Visual Studio Code, paired with the official Go extension from the Go Team at Google, is the most popular editor setup for Go development, offering autocompletion, inline error checking, formatting on save, and integrated debugging.

  • Install Visual Studio Code from code.visualstudio.com.
  • Open the Extensions panel (Ctrl+Shift+X / Cmd+Shift+X) and install the "Go" extension published by the Go Team at Google.
  • Open any .go file; VS Code will prompt you to install supporting tools (gopls, dlv, etc.) — click "Install All."
  • Enable "format on save" so your code is automatically run through gofmt every time you save.

Common Mistakes

Avoid These Mistakes
  • Forgetting to open a new terminal window after installing — the old window won't see the updated PATH.
  • Manually configuring GOPATH out of habit from old tutorials — modern Go projects don't require it.
  • Downloading Go from unofficial third-party sites instead of the official go.dev/dl page.
  • Skipping the VS Code Go extension's "Install All" prompt, then wondering why autocomplete and formatting aren't working.

Best Practices

  • Always run `go mod init <module-path>` at the start of a new project.
  • Keep Go updated to a recent stable release to get the latest performance and security improvements.
  • Enable format-on-save in your editor so your code always matches idiomatic gofmt style automatically.
  • Bookmark go.dev/doc for official setup guides in case your platform needs slightly different steps.

Frequently Asked Questions

No, not for typical modern development. Go Modules (default since Go 1.16) let you place projects anywhere; GOPATH is now mainly used internally for caching downloaded modules.

VS Code with the official Go extension is the most popular choice and works great for beginners and professionals alike. GoLand (JetBrains) is a strong paid alternative with deeper IDE features.

Simply download and run the newer installer for your platform from go.dev/dl — it replaces the previous version. On macOS with Homebrew, run `brew upgrade go`.

Key Takeaways

  • Download Go only from the official go.dev/dl page for your operating system.
  • Verify your installation with `go version` in a fresh terminal window.
  • Modern Go projects use Go Modules (`go mod init`), not the legacy GOPATH workflow.
  • VS Code with the official Go extension is the recommended editor setup for this course.

Summary

You now have Go installed and verified, understand the modern Go Modules workflow, and have your editor configured. Next, you'll write, run, and build your very first complete Go program from scratch.

Next Lesson →

Your First Go Program