How to install GO language on Ubuntu 18.04?

GO Language
GO Language

The world of software development is a complex world. Every day new and better features emerge that force developers to broaden their range of knowledge. However, not all these technologies are complex to assimilate, and for this purpose, I will teach you how to install GO language in Ubuntu 18.04.

Go is an open source (BSD license) programming language that was born with the objective of allowing the creation of efficient and easily distributable applications. So, it has binaries for Windows, Mac OS and of course, for Linux.

So, in this post, I will install it and create a “Hello World” file for the test.

1. Install GO Language

The installation of GO is quite simple, just download the binaries and move them to the preferred location. Of course, you can also check that the installation is correct through the key.

So, install wget package.

:~$ sudo apt install wget

Then, download GO binaries.

:~$ wget
1.- Downloading GO
1.- Download and install GO

Note: At the time of writing this post the latest stable version of GO is 1.11.4.

Now, it is necessary to decompress the file.

:~$ tar xvf go1.11.4.linux-amd64.tar.gz

Next, Next, change the owner of the folder and move it to /usr/local/.

:~$ sudo chown -R root:root go
:~$ sudo mv go /usr/local
2.- Moving the binaries to the recommended path
2.- Moving the binaries to the recommended path

Many people prefer to change the route to another, but the recommended one is /usr/local/.

2. Working with the paths

Now you need to make some adjustments to your GO routes. For example, set Go’s root value, which tells Go where to look for its files.

:~$ sudo nano ~/.profile

At he end of the file add the following:

export GOROOT=$HOME/go
export GOPATH=$HOME/work
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

Note: These parameters work if GO was installed in the personal folder. If this is not the case, you must specify the paths.

In this case:

export GOROOT=/usr/local/go    
export GOPATH=$HOME/work/
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
Setting the paths
3.- Setting the paths

Now, for the changes to take effect, it is necessary to refresh your bash profile.

:~$ source ~/.profile
4.- Refreshing the bash profile
4.- Refreshing the bash profile

Check the GO version installed.

:~$ go version
Checking the GO version
5.- Checking the GO version

3. Creating a Hello World file

Now to check that everything is OK, you need to create a GO file and run it.

First, create the GO workspace. Don’t worry, it is a folder. I will call it work. Look at the above image.

:~$ mkdir -p $HOME/work/src/hello
Creating the workspace for GO
6.- Creating the workspace for GO

Then, create the first GO file.

:~$ nano ~/work/src/hello/hello.go

Now, add these lines.

package main 
import "fmt"
func main() {
fmt.Printf("hello, world\n")
Creating the hello world file
7. Creating the hello world file

Now, compile the file, install the package generated and then run it.

:~$ go build hello
:~$ go install hello
:~$ hello
Running the file
8.- Running the file

And that’s it.


GO is a very popular language and every day it is more and more popular. It’s simple but very powerful, besides being open source. As you have seen, its installation is really simple.

Please share this article in your social networks.

You can also read “How to install Ruby on Rails on Debian 9“.


Please enter your comment!
Please enter your name here