Getting Started with Golang Installation on Linux, Windows, and macOS

pkshahid
2 min readAug 19, 2023

--

Are you eager to explore the world of Go (or Golang) programming? This powerful and efficient programming language is known for its simplicity, speed, and extensive standard library. Before diving into your first Go project, you’ll need to set up the development environment. In this guide, we’ll walk you through the installation process on Linux, Windows, and macOS, making it easy for you to start your Go journey.

Installing Go on Linux:

  1. Package Manager : Many Linux distributions offer Go in their package repositories. On Debian-based systems, you can use the following commands:
sudo apt update
sudo apt install golang

Alternatively,

sudo apt update
sudo snap install golang

On Red Hat-based systems:

sudo dnf install golang

2. Manual Installation (recommended) : you can download the official Go binary from the Go Downloads page and follow the installation instructions.

Remove any previous Go installation by deleting the /usr/local/go folder (if it exists), then extract the archive you just downloaded into /usr/local, creating a fresh Go tree in /usr/local/go

 rm -rf /usr/local/go && tar -C /usr/local -xzf go1.21.0.linux-amd64.tar.gz

Note : replace go1.21.0.linux-amd64.tar.gz with the filename downloaded.

Add /usr/local/go/bin to the PATH environment variable. Add the following line to your $HOME/.profile or /etc/profile (for a system-wide installation).

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

Changes made to a profile file may not apply until the next time you log into your computer. To apply the changes immediately, just run the shell commands directly or execute them from the profile using a command such as source $HOME/.profile.

Installing Go on Windows:

  1. Installer: Visit the Go Downloads page and download the Windows installer. Run the installer and follow the prompts to complete the installation.
  2. Manual Installation: If you prefer manual installation, download the zip archive from the Go Downloads page. Extract the contents to a directory of your choice and add the Go binary directory to your system’s PATH environment variable.

Installing Go on macOS:

1.Homebrew : If you have Homebrew installed, you can simply run:

brew install go

2.Package Installer: Visit the Go Downloads page and download the macOS package installer. Run the installer and follow the instructions.

Verifying Your Installation:

Regardless of your operating system, you can verify that Go is installed correctly by opening a terminal and running the following command:

go version

You should see the installed Go version printed on the screen.

You’re all set!

--

--

pkshahid

Full-stack web developer who always looking to learn and improve. Skilled in Python,Golang,NodeJs,Django.