Golang on Linux Mint 18

Go, or Golang, is an open source programming language from Google. Released in late-2009, it has since become a very popular programming language. Docker and many of its tools are written in Go, as are many new Web applications.

Unlike Python, it doesn’t come pre-installed on most Linux distributions, though its installation packages are likely in the official package repositories of your favorite Linux distribution. However, it is also likely that that package is one or two revisions behind the latest version. And that is the case with Ubuntu 17.04, where the version in the repository is v1.6. The latest version is v1.8.3.

So in this tutorial, we’ll go through the process of installing Go 1.8.3 on Ubuntu 17.04. That process involves downloading the Go binary from the project’s download page, copying it to the appropriate system directory, and setting up a Go workspace on the target system. The same method may also be used to install it on a related distribution, like Linux Mint 18.2, or even Debian 9 or Debian 8.

Download and Install the Go Binary

The Go binary is available for download from the project’s download page. Use the following commands to download and install it on your system:

With that, Go 1.8.3 is now installed on your system. But I’m sure you noticed that the last two commands above were executed by specifying their absolute paths. That’s not how it should be, so the next task is to add the Go installation bin directory to your PATH.

Add the Go Installation bin Directory to PATH

To make the newly-installed Go tools available in your PATH, so that you can execute the go command without needing to specify the absolute PATH, you’ll need to add the Go bin directory (/usr/local/go/bin) to the PATH environment variable, either system wide in the /etc/profile directory, or in your ~/.profile file. It can also go in your ~/.bashrc file or wherever you have PATH defined. Use the following commands to modify the PATH definition in your ~/.profile file:

Related Post:  Ubuntu is not a community distribution

With that last command, you can now execute go without needing to specify the absolute PATH. Just type go ….

Make GOPATH Available to Bash

Installation of Go adds more than twenty new environmental variables to the system (to view them, type go env), one of which is GOPATH, which points to the workspace (projects directory structure) for your Go projects. By default, it points to a directory named go in your home directory, that is, ~/go or $HOME/go. You may continuing using the default, or change it. In this tutorial, we’ll stick with the default.

To make GOPATH available to Bash, add it to your Bash profile file or wherever you defined PATH. For this tutorial, we’ll add in the ~/.profile. You may do so using the following commands:

Test Your Go Installation

Here we’ll set up an example Go program named Hello World! to test whether our installation of Go works. If Go can run it successfully, then Go is truly set to go. We’ll create the source directory for the program under GOPATH. Use the following commands to set up the program’s structure using github.com/your-username, gitlab.com/your-username or any other application that you use as the base path:

Inside the hello directory you created using the last command, create a file named hello.go and copy and paste the following code into it. All the code does is emit the famous Hello, world! greeting.

Related Post:  Install HY-D-V1 desktop on Ubuntu 13.04

Save and close the file. Use the next command to compile the program:

If the code compiled successfully, there should now be an executable named hello in the bin directory of your Go workspace. And if you run the command, you’ll get the expected output, as shown here:

If you got the correct output as in the above code, then you’ve successfully installed Go on your Ubuntu 17.04 installation. To make running your new Go executables easier, let’s add the bin directory of your GOPATH to PATH, so you won’t have to specify the absolute paths as in the above command.

Add GOPATH bin Directory to PATH

In this final and last section, we’ll add the bin directory of your GOPATH directory to your PATH. Since we already modified PATH earlier, we’ll just append the new entry to it using the following commands:

That’s it! You just installed Go 1.8.3 on Ubuntu 17.04 and you can execute new Go commands by specifying just the relative paths. To learn more about Go and how to start developing Go applications, click here.

Golang logo


Share on facebook
Share on twitter
Share on pinterest
Share on linkedin

Hola! Did you notice that LinuxBSDos.com no longer runs network ads?  Yep, no more ads from the usual suspects that track you across the Internet.  But since  I still need to pay to keep the site running, feel free to make a small donation by PayPal.

Subscribe for updates. Trust me, no spam!

Mailchimp Signup Form

Sponsored links

1. Attend Algorithm Conference, a top AI and ML event for 2020.
2. Reasons to use control panel for your server.
3. DHgate Computers Electronics, Cell Phones & more.

One Response

  1. Testing of the version
    In my case it was: /usr/local/go/bin/go version

    The code highlighter is a bit strange, it removes the selection by using a magic algorithm, could you improve it ?

Leave a Reply

Your email address will not be published. Required fields are marked *

Get the latest

On social media
Via my newsletter
Mailchimp Signup Form

Sponsored links

1. Attend Algorithm Conference, a top AI and ML event for 2020.
2. Reasons to use control panel for your server.
3. DHgate Computers Electronics, Cell Phones & more.
Hacking, pentesting distributions

Linux Distributions for Hacking

Experts use these Linux distributions for hacking, digital forensics, and pentesting.


The authors of these books are confirmed to speak during

Algorithm Conference

T-minus AI

Author was the first chairperson of AI for the U.S. Air Force.

The case for killer robots

Author is the Director of the Center for Natural and Artificial Intelligence.

Why greatness cannot be planned

Author works on AI safety as a Senior Research Scientist at Uber AI Labs.

Anastasia Marchenkova

An invitation from Anastasia Marchenkova

Hya, after stints as a quantum researcher at Georgia Tech Quantum Optics & Quantum Telecom Lab, and the University of Maryland Joint Quantum Institute, I’m now working on superconducting qubit quantum processors at Bleximo. I’ll be speaking during Algorithm Conference in Austin, Texas, July 16 – 18, 2020. Meet me there and let’s chat about progress and hype in quantum computing.