Running sudo apt-get install golang-stable
, I get Go version go1.0.3
. Is there any way to install go1.1.1
?
Remove the existing Go version:
sudo apt-get purge golang*
Install the latest version of Go:
sudo add-apt-repository ppa:longsleep/golang-backports
sudo apt-get update
sudo apt-get install golang-go
Create the .profile
file in the home path with this content:
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.
# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022
# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
# set PATH so it includes user's private bin directories
PATH="$HOME/bin:$HOME/.local/bin:$PATH"
Set Go workspace to the environment variable:
GOPATH=~/.go
Apply the .profile
configuration:
source ~/.profile
Test:
$ go version
go version go1.11.1 linux/amd64
Ref: Go-GitHub-Installation
I used following commands from GoLang official repository, it installed GoLang version 1.6 on my Ubuntu 14.04
sudo add-apt-repository ppa:ubuntu-lxc/lxd-stable
sudo apt-get update
sudo apt-get install golang
Reference official GoLang Repo https://github.com/golang/go/wiki/Ubuntu it seems this ppa will always be updated in future.
Here is the most straight forward and simple method I found to install go on Ubuntu 14.04 without any ppa or any other tool.
As of now, The version of GO is 1.7
Get the Go 1.7.tar.gz using wget
wget https://storage.googleapis.com/golang/go1.7.linux-amd64.tar.gz
Extract it and copy it to /usr/local/
sudo tar -C /usr/local -xzvf go1.7.linux-amd64.tar.gz
You have now successfully installed GO. Now You have to set Environment Variables so you can use the go
command from anywhere.
To achieve this we need to add a line to .bashrc
So,
sudo nano ~/.bashrc
and add the following line to the end of file.
export PATH="/usr/local/go/bin:$PATH"
Now, All the commands in go/bin
will work.
Check if the install was successful by doing
go version
For offline Documentation you can do
godoc -http=:6060
Offline documentation will be available at http://localhost:6060
NOTE:
Some people here are suggesting to change the PATH variable.
It is not a good choice.
Changing that to /usr/local/go/bin
is temporary and it'll reset once you close terminal.
go
command will only work in terminal in which you changed the value of PATH.
You'll not be able to use any other command like ls, nano
or just about everything because everything else is in /usr/bin
or in other locations. All those things will stop working and it'll start giving you error.
However, this is permanent and does not disturbs anything else.
Or maybe you could use this script to install Go and LiteIDE?
If you are unhappy with the answer provided, please comment instead of blindly down voting. I have used this setup for the last 4 years without any issue.
i installed from source. there is a step-by-step tutorial here: http://golang.org/doc/install/source
If you have ubuntu-mate, you can install latest go by:
umake go
I have a script to download and install the last go from official website
# Change these varialbe to where ever you feel comfortable
DOWNLOAD_DIR=${HOME}/Downloads/GoLang
INSTALL_DIR=${HOME}/App
function install {
mkdir -p ${DOWNLOAD_DIR}
cd ${DOWNLOAD_DIR}
echo "Fetching latest Go version..."
typeset VER=`curl -s https://golang.org/dl/ | grep -m 1 -o 'go\([0-9]\)\+\(\.[0-9]\)\+'`
if uname -m | grep 64 > /dev/null; then
typeset ARCH=amd64
else
typeset ARCH=386
fi
typeset FILE=$VER.linux-$ARCH
if [[ ! -e ${FILE}.tar.gz ]]; then
echo "Downloading '$FILE' ..."
wget https://storage.googleapis.com/golang/${FILE}.tar.gz
fi
echo "Installing ${FILE} ..."
tar zxfC ${FILE}.tar.gz ${INSTALL_DIR}
echo "Go is installed"
}
install
Setup your GOROOT, GOPATH and PATH:
export GOROOT=${INSTALL_DIR}/go
export GOPATH=<your go path>
export PATH=${PATH}:${GOROOT}/bin:${GOPATH}/bin