beginner getting started

Installing Go & Setting Up Your Environment

Learn how to download and install Go on Windows, macOS, and Linux. Set up your GOPATH, GOROOT, and write your first program.

installation environment setup

Why Go?

Go (often called Golang) is an open-source programming language created at Google in 2007 and released to the public in 2009. It was designed by Robert Griesemer, Rob Pike, and Ken Thompson to address the challenges of modern software development at scale.

Go is known for being:

  • Fast — Compiles to native machine code
  • Simple — Clean syntax with only 25 keywords
  • Concurrent — Built-in goroutines and channels
  • Efficient — Garbage collected, yet lightweight

Installing Go

Windows

  1. Download the MSI installer from go.dev/dl
  2. Run the installer and follow the prompts
  3. The installer will set up GOROOT and add Go to your PATH

macOS

Terminal window
# Using Homebrew
brew install go
# Or download the .pkg installer from go.dev/dl

Linux

Terminal window
# Download the tarball
wget https://go.dev/dl/go1.23.0.linux-amd64.tar.gz
# Extract to /usr/local
sudo tar -C /usr/local -xzf go1.23.0.linux-amd64.tar.gz
# Add to PATH
echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.bashrc
source ~/.bashrc

Verifying Installation

Open a terminal and run:

Terminal window
go version

You should see output like:

go version go1.23.0 windows/amd64

Understanding Key Environment Variables

VariablePurpose
GOROOTWhere Go is installed (usually /usr/local/go)
GOPATHWhere your Go projects and dependencies live
GOBINWhere compiled binaries are placed

Modern Go (1.16+) uses modules by default, so you don’t need to set GOPATH for most projects anymore.

Your First Project Structure

myapp/
├── go.mod
├── main.go

Create go.mod:

Terminal window
go mod init myapp

This creates a module definition file that tracks your dependencies.

Next Steps

Now that Go is installed, let’s write your very first program: Hello, World!