Installing Go: Let's get Started!
Learn how to install Golang (Go) on Windows, macOS, and Linux. This beginner-friendly guide walks you through each step to get started with Golang quickly.
If you’re diving into Go (often referred to as Golang), the first step is installing the programming language on your machine. Whether you’re using Windows, macOS, or Linux, this guide will walk you through the process of installing Golang quickly and efficiently.
Why Choose Go?
Before jumping into the installation steps, let’s take a moment to understand why Go has become a popular language:
- Fast and efficient: Go is designed for speed!
- Concurrency: Go has in-built support for concurrent programming, making it ideal for systems that need scale.
- Simplicity: it’s very easy to learn.
- Cross-platform: Write once, run anywhere—Go supports multiple platforms.
Let’s install it!
Installing Golang on Windows
Step 1: Download Golang
- Head to the official page to download it.
- Select the appropriate installer for Windows (
.msi
file). - Once the download is complete, run the installer.
That’s really it!
Step 2: Install Golang
- Follow the on-screen instructions in the installer to install Go.
- The default installation path is
C:Go
. You can change it, but it’s recommended to keep the default path.
Step 3: Set Up Environment Variables
To ensure you can run go
commands from any terminal window, add Go’s binary directory to your PATH
.
- Right-click on This PC or My Computer, and click Properties.
- Click on Advanced system settings, then Environment Variables.
- In the System variables section, find the
Path
variable, select it, and click Edit. - Click New, and enter the path to Go’s
bin
directory (C:Gobin
by default). - Click OK to save and close.
Step 4: Verify Installation
Open a command prompt and type:
go version
If the installation was successful, you should see the installed Go version displayed.
Installing Golang on macOS
Step 1: Download Golang
- Visit the official Go Downloads page.
- Download the
.pkg
installer for macOS.
Step 2: Install Golang
- Run the
.pkg
file and follow the instructions to install Go on your Mac. - The installer will automatically install Go to
/usr/local/go
.
Step 3: Set Up Environment Variables
To ensure Go works from your terminal, add it to your PATH
.
- Open the Terminal.
- Run the following command to add Go to your path in your
.bash_profile
or.zshrc
file:
echo "export PATH=$PATH:/usr/local/go/bin" >> ~/.bash_profile
source ~/.bash_profile
Step 4: Verify Installation
Once the installation is complete, verify it by running:
go version
You should see the Go version printed in the terminal.
Installing Golang on Linux
Step 1: Download Golang
Go to the official Go Downloads page and download the latest .tar.gz
archive for Linux.
Step 2: Install Golang
- Open a terminal and navigate to the directory where the
.tar.gz
file was downloaded. - Extract the archive and move it to
/usr/local
:
sudo tar -C /usr/local -xzf go1.x.x.linux-amd64.tar.gz
(Replace go1.x.x
with the actual version you downloaded.)
Step 3: Set Up Environment Variables
Add Go’s bin
directory to your PATH
.
- Open your shell profile (
.bashrc
,.bash_profile
, or.zshrc
). - Add the following line:
export PATH=$PATH:/usr/local/go/bin
- Save the file and reload it:
source ~/.bashrc
Step 4: Verify Installation
Check if Go is installed correctly:
go version
Wrapping Up
Installing Golang is pretty easy on any operating system.
Now that you have Go installed, you can start exploring - this website has books, courses, and blog posts that can help so have a click around.