Running sudo apt-get install golang-stable
, I get Go version go1.0.3
. Is there any way to install go1.1.1
?
[October 2015]
Answer because the current accepted answersudo apt-get install golang
isn't uptodate and if you don't want to install GVM
follow these steps.
sudo tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz
go
to your path export PATH=$PATH:/usr/local/go/bin
go version
to check the current version installedIf you get a go version xgcc (Ubuntu 4.9.1-0ubuntu1) 4.9.1 linux/amd64
then you did something wrong, so check out this post: Go is printing xgcc version but not go installed version
You can use a script from udhos/update-golang.
Here is a two-liner as example (run as root
):
bash <(curl -s https://raw.githubusercontent.com/udhos/update-golang/master/update-golang.sh)
ln -vs /usr/local/go/bin/go* /usr/local/bin/
Best way to install Go on Ubuntu is to download required version from here. Here you could have all stable and releases, along with archived versions.
after downloading you selected version you can follow further steps, i will suggest you to download tar.gz format for ubuntu machine:
sudo rm -rf /usr/local/go /usr/local/gocache
this will remove all the local go code base but wait something more we have to do to remove fully from local, i was missing this step and it took so much time until I understood what i am missing so here is the purge stuff to remove from list
sudo apt-get purge golang
or
sudo apt remove golang-go
tar -C /usr/local -xzf go1.10.8.linux-amd64.tar.gz
GOROOT
variable value you can check the value by go env
if not set then export PATH=$PATH:/usr/local/go
/home/yourusername/go/test.php
if you haven't changed set GOPATH
value:package main import "fmt" func main() { fmt.Println("hello world") }
go run test.go
i hope it works for you!!
- Download say,
go1.6beta1.linux-amd64.tar.gz
from https://golang.org/dl/ into/tmp
wget https://storage.googleapis.com/golang/go1.6beta1.linux-amd64.tar.gz -o /tmp/go1.6beta1.linux-amd64.tar.gz
- un-tar into
/usr/local/bin
sudo tar -zxvf go1.6beta1.linux-amd64.tar.gz -C /usr/local/bin/
- Set GOROOT, GOPATH, [on ubuntu add following to ~/.bashrc]
mkdir ~/go
export GOPATH=~/go
export PATH=$PATH:$GOPATH/bin
export GOROOT=/usr/local/bin/go
export PATH=$PATH:$GOROOT/bin
- Verify
go version
should show be
go version go1.6beta1 linux/amd64
go env
should show be
GOARCH="amd64" GOBIN="" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOOS="linux" GOPATH="/home/vats/go" GORACE="" GOROOT="/usr/local/bin/go" GOTOOLDIR="/usr/local/bin/go/pkg/tool/linux_amd64" GO15VENDOREXPERIMENT="1" CC="gcc" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0" CXX="g++" CGO_ENABLED="1"
For the current release of Go:
The Go Programming Language
Getting Started
Download the Go distribution
Downloads
Click the link above to visit the Go project's downloads page and select the binary distribution that matches your operating system and processor architecture.
Official binary distributions are available for the FreeBSD, Linux, macOS, and Windows operating systems and the 32-bit (386) and 64-bit (amd64) x86 processor architectures.
If a binary distribution is not available for your combination of operating system and architecture you may want to try installing from source or installing gccgo instead of gc.
Installing Go from source