You could earn up to $300 by adding new articles!

Get Started Now

How to Install Golang 1.8 on Ubuntu 16.04

Published on: Thu, Dec 28, 2017 at 5:57 pm EST

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 ~

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 Vultr\n");

You can run this test script with the following.

go run hello.go

The message "Hello Vultr" will show in your terminal.

Want to contribute ?

You could earn up to $300 by adding new articles!

Get started in the SSD Cloud!