Installing Go (golang)
Go is a programming language generally referenced as ‘golang’ because ‘go’ brings numerous results in search engines. You can learn more at https://golang.org.
By Marcelo Martins - March 01, 2020
1. Introduction Permalink
Go is a programming language generally referenced as ‘golang’ because ‘go’ brings numerous results in search engines. You can learn more at https://golang.org.
Go is the language used in the Decred Project and is a prerequisite for virtually all source code made available by developers, as well as for some tools only available in source code. This article shows the step-by-step installation of Go and will be referenced whenever Go is a prerequisite.
This installation is not required for Decrediton or Decred binaries users.
2. Installing Golang Permalink
To compile the source code of the components of Decred Project, it is necessary at the moment to have at least Go 1.12 or 1.13 installed. Unfortunately, the required version may not be available via apt-get for the version of your Linux distribution. If the official repository makes available the version we need, the installation will be easily done using:
$ sudo apt-get install golang
Otherwise, the installation needs to be done manually. The following steps were performed on a Debian 9 64-bit.
$VERSION represents the version number, like “1.14” and $ARCH represents ‘386’, ‘amd64’, ‘arm’ or ‘arm64’.
a) Go to https://golang.org/dl/ and download Go for Linux, which will be named go$VERSION.linux-$ARCH.tar.gz
. Download can also happen through wget
or curl
.
$ wget https://dl.google.com/go/go$VERSION.linux-$ARCH.tar.gz
b) Go to the prompt of the Downloads folder and unzip the tarball into /usr/local directory:
$ cd $HOME/Downloads
$ sudo tar -C /usr/local -xzf go$VERSION.linux-$ARCH.tar.gz
c) Export Go executable path to your PATH:
$ export PATH=$PATH:/usr/local/go/bin
Depending on your server role, you may even remove the old version using:
$ sudo apt remove golang
If you keep more than one version of Go, make sure that the correct version is being executed. If you keep only one version, make sure it is accessible via PATH:
$ which go
$ go version
To set up the PATH
permanently for all users, include this command in a shell script inside directory /etc/profile.d/
, or inside ~/.bashrc
, for the current user only:
export PATH=$PATH:/usr/local/go/bin
Comments ()