Difference between revisions of "Golang/Install"
< Golang
Jump to navigation
Jump to search
(Created page with "= Ubuntu Install = Ubuntu LTS 16.04 = Multiple versions = You can have multiple versions fo Golang installed in your system. The way to manage the current version in use is t...") |
|||
Line 1: | Line 1: | ||
= Ubuntu Install = | = Ubuntu Install = | ||
Ubuntu LTS 16.04 | Ubuntu LTS 16.04 | ||
Download from https://golang.org/dl/ and extract it into <coede>/usr/local</code>, creating a Go tree in <code>/usr/local/go</code> | |||
<source> | |||
sudo tar -C /usr/local -xzvf go$VERSION.$OS-$ARCH.tar.gz | |||
</source> | |||
Add /usr/local/go/bin to the PATH environment variable. You can do this by adding this line to your <tt>/etc/profile</tt> (for a system-wide installation) or <tt>$HOME/.profile</tt>: | |||
<source> | |||
export PATH=$PATH:/usr/local/go/bin | |||
</source> | |||
= Multiple versions = | = Multiple versions = |
Revision as of 15:19, 2 June 2018
Ubuntu Install
Ubuntu LTS 16.04
Download from https://golang.org/dl/ and extract it into <coede>/usr/local, creating a Go tree in /usr/local/go
sudo tar -C /usr/local -xzvf go$VERSION.$OS-$ARCH.tar.gz
Add /usr/local/go/bin to the PATH environment variable. You can do this by adding this line to your /etc/profile (for a system-wide installation) or $HOME/.profile:
export PATH=$PATH:/usr/local/go/bin
Multiple versions
You can have multiple versions fo Golang installed in your system. The way to manage the current version in use is to use update-alternatives
Before
Selection Path Priority Status ------------------------------------------------------------ 0 /usr/bin/golang-go 10 auto mode 1 /usr/bin/gccgo-go 5 manual mode 2 /usr/bin/golang-go 10 manual mode
Installed manually unzipped GoLang into /usr/local/go but was not added to alternatives. Use command below to add it on:
sudo update-alternatives --install "/usr/bin/go" "go" "/usr/local/go/bin/go" 2
After
Selection Path Priority Status ------------------------------------------------------------ * 0 /usr/bin/golang-go 10 auto mode 1 /usr/bin/gccgo-go 5 manual mode 2 /usr/bin/golang-go 10 manual mode 3 /usr/local/go/bin/go 2 manual mode
Then run command to change go binary available in your shell
sudo update-alternatives --config go #then select 3
When you run
$ go version #the version of go will be the one from /usr/local/go location.