Go has released the latest version 1.7. This tutorial will help you install Go 1.7 on your Ubuntu 16.04,14.04 and 12.04 LTS system.
Step 1 - Install Go Language
Use ssh to log in to your Ubuntu system, and upgrade the application to have the latest security updates.sudo apt-get update sudo apt-get -y upgrade
Now, use the following link to download the binary archive Go language. To find and download the latest version available or a 32-bit version, please visit the official download page .
wget https://storage.googleapis.com/golang/go1.7.linux-amd64.tar.gz
Now, extract the compressed files to download and install the desired location in the system. In this tutorial, I installed under the / usr / local directory. You can also put the home directory (shared hosting) below or elsewhere.
sudo tar -xvf go1.7.linux-amd64.tar.gz sudo mv go /usr/local
Step 2 - Set Go environment
Now, you need to set the environment variable to the language for your project. Usually you need to set three environment variables GOROOT, GOPATH and the PATH . GOROOT is the location of the packages installed on the system.
export GOROOT=/usr/local/go
GOPATH is the location of your working directory. For example, my project directory is ~ / the Projects / Proj1 .
export GOROOT=$HOME/Projects/Proj1
Now set the PATH variable to access the Go bin system.
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
All of the above environment will be provided only for the current session. In order to make ~ / .profile file becomes a permanent addition of the command.
Step 3 - Verify Installation
In this step, you have successfully installed and configured the Go language on the system. Go first check the version using the following command.
go version go version go1.7 linux/amd64
Now you can also use the following command to verify all configuration environment variable.
go env GOARCH="amd64" GOBIN="" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOOS="linux" GOPATH="/home/tecadmin/Projects/Proj1" GORACE="" GOROOT="/usr/local/go" GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64" CC="gcc" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build661994963=/tmp/go-build" CXX="g++" CGO_ENABLED="1"