Installing Go (Golang) on Linux, macOS, and Windows: A Step-by-Step Guide

JAY BHATT
2 min readOct 7, 2023

Go, also known as Golang, is a popular programming language for its simplicity and efficiency. Whether you’re on Linux, macOS, or Windows, installing Go is a straightforward process. In this guide, we’ll walk you through the essential commands to get Go up and running on your system.

Linux Installation:

Begin by downloading the latest Go binary release using wget:

wget https://golang.org/dl/go1.21.2.linux-amd64.tar.gz

Extract the downloaded Go binary release:

tar -xf go1.21.2.linux-amd64.tar.gz

Move the Go binary directory to /usr/local/go:

sudo mv go /usr/local/go

Add the Go bin directory to your PATH environment variable:

sudo echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.bashrc

Reload your .bashrc file to apply changes:

source ~/.bashrc

Verify that Go is installed successfully by running:

go version

macOS Installation:

Download the latest Go package file using curl:

curl -o go1.21.2.darwin-amd64.pkg https://golang.org/dl/go1.21.2.darwin-amd64.pkg

Open and install the downloaded Go package file using sudo installer:

sudo installer -pkg go1.21.2.darwin-amd64.pkg

Verify that Go is installed by running:

go version

Windows Installation:

Download the latest Go MSI installer using curl or your web browser.

# Download the latest Go MSI installer
curl -o go1.21.2.windows-amd64.msi https://golang.org/dl/go1.21.2.windows-amd64.msi

Double-click the Go MSI installer to start the installation process
Follow the on-screen instructions to complete the installation

Verify that Go is installed by running:

# Verify that Go is installed
go version

Additional Commands:

  • To install an older version of Go, replace the version number in the download URL with the desired version.
  • To install Go to a different location, specify the location using the -d option during installation.
  • To install Go for a specific user, install the Go binary directory or package file in the user’s home directory.
  • To uninstall Go, remove the Go binary directory or package file and remove the Go bin directory from your PATH environment variable.

These commands provide a basic setup of Go on various operating systems. Depending on your specific configuration, additional steps may be necessary. For more detailed instructions, please consult the official Go installation documentation.

Conclusion:

Installing Go on Linux, macOS, or Windows is an essential step for any developer looking to work with this versatile programming language. By following the provided commands, you can easily set up Go on your preferred operating system and start coding with Go’s speed and efficiency. Remember to check the official Go documentation for any updates or additional requirements specific to your environment.Happy coding with Go!

--

--

JAY BHATT

Cyber Security Enthusiast |Top 1% on TryHackMe |CTF Player