To get started with learning Golang, you’ll need to install it on your computer. The good news is that Golang can be easily installed on any operating system, including Linux, Windows, and MacOS.
Install Golang on Linux
There are several ways to install Go on a Linux system.
The first method is to install the default Go version included with your Linux distribution. However, this may not always be the latest version available.
For instance, if you install Go on Ubuntu 22.04 using the default method, you will get version go1.18, while the latest version at the time of writing is go1.20.2.
To install the default Go version, simply use the default package manager as shown:
$ sudo apt install golang [On Debian, Ubuntu and Mint] $ sudo yum install golang [On RHEL/CentOS/Fedora and Rocky/AlmaLinux] $ sudo emerge -a dev-lang/go [On Gentoo Linux] $ sudo apk add golang [On Alpine Linux] $ sudo pacman -S golang [On Arch Linux] $ sudo zypper install golang [On OpenSUSE]
The second method is to use Snap, a package management system developed by Canonical, which is used to install the latest stable version of Go as shown.
$ sudo snap install --classic --channel=1.20/stable go
The third way is to download the Go binary, and run the following command to install it:
$ wget https://go.dev/dl/go1.20.2.linux-amd64.tar.gz $ tar -xvf go1.20.2.linux-amd64.tar.gz $ sudo mv go /usr/local $ export PATH=$PATH:/usr/local/go/bin
Note that in this example, we’re using the 64-bit version. You can choose a different version based on your system architecture.
After the installation is complete, you can check the Go version installed using the command:
$ go version
These are three ways to install Go on a Linux system. Choose the one that works best for you depending on your needs and preferences.
Install Golang on Windows
Installing Golang on a Windows system is a straightforward process, similar to installing any other application.
First, download the Golang Windows installer and run the installer file as shown.
Once the installation is complete, a “golang” folder will be created on the C
drive. To confirm that Golang is installed correctly on your system, open the command prompt and enter the following command:
go version
This will display the installed version of Golang in the Windows system.
Install Golang on Mac
Installing Golang on Mac OS is a straightforward process, similar to Windows.
First, download the Golang .pkg installer, run the installer file, and follow the on-screen instructions.
Once the installation is complete, verify that Golang is installed correctly by running the following command:
go version
This should display the installed Golang version.
In conclusion, Golang provides installers and source code for installing Golang on all major operating systems, including Windows, Linux, and Mac OS.