Installing Golang
While there is an official doc on installing Golang it is less than helpful for Linux users. We are attempting to collect the best practices in installing Golang for beginners here.
Tip
If you are using Goland as an IDE you can skip this step. Goland downloads the Go compiler for you.
Ubuntu 20.04
On Ubuntu 20.04 you can install Go directly from the package manager:
apt update
apt install golang-1.14
RHEL/CentOS
yum install golang-bin
Fedora
dnf install golang-bin
Gentoo Linux
emerge --ask dev-lang/go
Other / non-administrator
- Download the Linux .tar.gz.
- Extract the archive into a directory.
- Add the following section to your
~/.profile,~/.zshrc,~/.bashrc, or~/.bash_profile, depending on your shell, then restart your terminal:
export PATH=$PATH:/usr/local/bin/go
We also recommend adding ~/go/bin directory to your PATH.
** Install as administrator **
Golang offers an MSI-based installer for Windows that makes it easy to install Golang on your Windows machine. Follow the installation wizzard and the go command should start working in the terminal.
We also recommend adding %USERPROFILE%\go\bin to your PATH environment variable to enable running tools from your home directory.
** Install as user **
- Download the
ZIParchive from the archive page - Extract the ZIP file to a folder you have access to.
- Go to Control Panel → System and Security → System → Advanced system settings.
- Click on Environment variables...
- Change the
PATHenvironment variable to point to thebindirectory inside your Goland directory.
We also recommend adding %USERPROFILE%\go\bin to your PATH environment variable to enable running tools from your home directory.
Golang offers a PKG installer for MacOS. The go command will be located in /usr/local/go/bin. If the go command doesn't work try restarting the terminal.
If it still doesn't work try running the /usr/local/go/bin/go command. If that command works edit the ~/.profile, ~/.zshrc, or ~/.bash_profile files and add the following lines then restart your terminal:
export PATH=$PATH:/usr/local/bin/go
We also recommend adding ~/go/bin directory to your PATH.