Learn How To Install Golang 1.8 on Ubuntu 16.04
Table of Contents
Go (Golang) is a modern programming language developed at Google, and focused on simplicity and safety. It has become a popular language used for server-side development.
First, you need to download Golang.
cd ~
wget https://storage.googleapis.com/golang/go1.8.3.linux-amd64.tar.gz
Now, you need to decompress the files.
tar -xf go1.8.3.linux-amd64.tar.gz
Move the folder to /opt/
or some other directory of your choice. Remember that if you choose another directory, you need to correct the path accordingly in the next steps.
mv go /opt/
Add the environment
path.
mkdir /opt/gopkg
export GOPATH="/opt/gopkg"
export GOROOT="/opt/go"
Now you will need to add these to your PATH variable.
export PATH=$PATH:$GOPATH/bin:$GOROOT/bin
If you wish for the changes to be permanent, you will need to put the following commands into the .profile
file.
Open the file.
sudo nano ~/.profile
Insert the following at the end.
export GOPATH="/opt/gopkg"
export GOROOT="/opt/go"
export PATH=$PATH:$GOPATH/bin:$GOROOT/bin
Verify installation.
go version
Check the installation by running the go
command. When you run the command, you will see a list of options.
Create a file called hello.go
.
cd /opt/gopkg
nano hello.go
Insert the following code.
package main
import "fmt"
func main(){
fmt.Printf("Hello IT Web Servicesn");
}
You can run this test script with the following.
go run hello.go
The message “Hello IT Web Services” will show in your terminal.
Need help?
Do you need help setting up this on your own service?
Please contact us and we’ll provide you the best possible quote!