Installing a Go Development Environment¶
This guide walks you through setting up Git, Go, and a code editor on macOS, Windows, and Linux (Ubuntu).
🍎 macOS¶
If Homebrew is installed, you can install Git and Go with two commands:
Otherwise, follow the steps below.
1. Install Apple Command Line Tools¶
Before installing anything else, macOS needs its basic developer foundation.
- Open your Terminal (press
Cmd + Spaceand type "Terminal"). - Run:
- A popup will appear — click Install and agree to the terms.
2. Install Git¶
macOS ships with an outdated Git; install the official version.
- Download: Go to git-scm.com/download/mac.
- Use the binary installer package.
- Verify:
3. Install Go¶
- Download: Visit go.dev/dl and select the macOS installer (
.pkg). - Apple Silicon (M1/M2/M3/…): choose ARM64.
- Intel Mac: choose x86-64.
- Open the package and follow the wizard.
- Verify (open a new Terminal window):
4. Editor: Visual Studio Code (VS Code)¶
If you do not already have a favourite editor (Vim or Emacs work great too), install VS Code.
- Download: code.visualstudio.com.
- Unzip the download and drag Visual Studio Code into your Applications folder.
- Add the
codecommand to PATH: - Open VS Code, press
Cmd + Shift + P. - Type
shell commandand select "Shell Command: Install 'code' command in PATH". - Install the Go extension:
- Click the Extensions icon (four squares) in the left sidebar.
- Search for "Go" and install the one by the Go Team at Google.
🪟 Windows¶
1. Install Git¶
- Download: git-scm.com/download/win.
- Run the
.exeinstaller. On most screens you can click Next, but note: - Editor: choose "Visual Studio Code as Git's default editor" (if already installed).
- PATH: select "Git from the command line and also from 3rd-party software".
- Line endings: choose "Checkout Windows-style, commit Unix-style line endings".
- Verify — open Command Prompt (
Win + R, typecmd) and run:
2. Install Go¶
- Download: go.dev/dl — choose the Windows installer (
.msi). - Run the installer; it defaults to
C:\Program Files\Go. - Close any open Command Prompts, then open a new one.
- Verify:
You should see something like
go version go1.26.x windows/amd64.
3. Editor: Visual Studio Code (VS Code)¶
- Download: code.visualstudio.com.
- Run the installer and make sure "Add to PATH" is checked.
- Set up Go support:
- Open VS Code and click the Extensions icon (four squares).
- Search for "Go" (by the Go Team at Google) and click Install.
- Press
Ctrl + Shift + P, typeGo: Install/Update Tools, select all boxes, and click OK.
🐧 Linux (Ubuntu)¶
1. Install Git¶
Git is available in Ubuntu's package repository:
Verify:
2. Install Go¶
Ubuntu's packaged Go is often outdated. Install the latest version directly from the official site.
-
Download the Linux tarball from go.dev/dl (choose the
Replace the filename with the latest version shown on the downloads page.linux-amd64build for most machines): -
Extract to
/usr/local(this is the standard location): -
Add Go to your PATH. Append the following lines to
Then reload your shell:~/.bashrc(or~/.zshrcif you use Zsh): -
Verify:
3. Editor: Visual Studio Code (VS Code)¶
-
Install via Snap (simplest method):
Alternatively, download the.debpackage from code.visualstudio.com and install withsudo apt install ./code_*.deb. -
Install the Go extension:
- Click the Extensions icon (four squares) in the left sidebar.
- Search for "Go" and install the one by the Go Team at Google.
- Press
Ctrl + Shift + P, typeGo: Install/Update Tools, select all, and click OK.
Your First Program (Hello World)¶
Once Go is installed on any platform, verify everything works:
-
Create a project folder and initialise a module:
-
Create
main.go: -
Run it:
You should see Hello, Gopher! Your environment is ready. printed in the terminal.