Mint, Ubuntu

How to install Go on Linux Mint 18 18.1 and Ubuntu 16.04 16.10

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.

Unlike Python, it doesn’t come pre-installed on most Linux distributions, but I expect that to change soon. Before then, installing it on your favorite Linux distribution is a breeze, as its installation packages are in official package repositories.

In this tutorial, we’ll go through the process of installing it on Linux Mint 18 and 18.1 and Ubuntu 16.04 and 16.10.

Install Go on Linux Mint and Ubuntu

To install Go, fire up a terminal and type the following commands:

That’s just what you need to install it. The Go executable is expected to be in /usr/local/go, but on both Linux Mint 18/18.1 and Ubuntu 16.04/16.10, it’s actually installed in another (custom) location – /usr/bin/go. Because its parent directory – /usr/bin – is already in your PATH. Nothing to worry about here. Go is ready to go.

Test you Go Installation

Here we’ll set up a Go workspace and build an Hello World! program. If Go can run it successfully, then Go is truly set to go. For this tutorial, I’m calling the workspace gostuff, create it and ensure that it’s in your PATH. The following commands show how to create the workspace:

Related Post:  How to provision Dockerized hosts with Docker Machine from Linux Mint 18, 18.1

Afterwards, set the GOPATH environment variable to point to the new workspace. The best approach to this is to set it in the .profile file under your home directory. The following commands show how to go about it:

With that out of the way, we’ll need to create the directory structure for a Go project using the following command:

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

Related Post:  6 3D printing applications you can install on Fedora 25

If this is getting to be too long, don’t worry, we’re almost home. But we won’t get there until we compile the Go code using the next command:

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

That’s it! You just installed Go on Linux Mint 18/18.1 or on Ubuntu 16.04/16.10 and verified that it works. To learn more about Go and how to start developing Go applications, click here.

Golang on Linux Mint 18

LinuxBSDos needs your donation to continue!

I hope this article has saved you valuable time and effort to fix a problem that would have taken more time than is necessary. That makes me happy, and why I love doing this. But because more people than ever are reading articles like this with an adblocker, ad revenues have fallen to a level that's not enough to cover my operating costs. That's why I want to ask you a favor: To make a one-time or recurring donation to support this site and keep it going. It's a small favor, but every one counts. And you can make your donation using Patreon or directly via Paypal. Thank you for whatever donation you're able to make.

Donate via Patreon. Donate via Paypal.

Aside from donation, you may also signup to receive an email once I publish new content. Your email will not be shared or traded to anyone. And you can unsubscribe at any time.

Please share:

We Recommend These Vendors and Free Offers

Launch an SSD VPS in Europe, USA, Asia & Australia on Vultr's KVM-based Cloud platform starting at $5:00/month (15 GB SSD, 768 MB of RAM).

Deploy an SSD Cloud server in 55 seconds on DigitalOcean. Built for developers and starting at $5:00/month (20 GB SSD, 512 MB of RAM).

Want to become an expert ethical hacker and penetration tester? Request your free video training course of Online Penetration Testing and Ethical Hacking

Whether you're new to Linux or are a Linux guru, you can learn a lot more about the Linux kernel by requesting your free ebook of Linux Kernel In A Nutshell.


5 Comments

  1. Kurt Fitzner

    Can you add information on installing a more recent (1.7) version of Go for Mint and/or Ubuntu 16.04?

  2. To compile this on Mint 18 I had to do the following
    $ go build hello.go

    This created the executable hello in the directory and then I just ran it.
    $ hello
    Hello, world!

    The github and gitlab compile commands wouldn’t work for me.

  3. Something is missing, not working Mint 18 version:

    madis@k* ~ $ cat /etc/linuxmint/info
    RELEASE=18
    CODENAME=sarah
    EDITION=”Cinnamon 64-bit”
    DESCRIPTION=”Linux Mint 18 Sarah”
    DESKTOP=Gnome
    TOOLKIT=GTK
    NEW_FEATURES_URL=http://www.linuxmint.com/rel_sarah_cinnamon_whatsnew.php
    RELEASE_NOTES_URL=http://www.linuxmint.com/rel_sarah_cinnamon.php
    USER_GUIDE_URL=help:linuxmint
    GRUB_TITLE=Linux Mint 18 Cinnamon 64-bit
    madis@k* ~ $ sudo apt install go
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    E: Unable to locate package go

    • Something weird happened between when I wrote that article and today. That package is no longer available. Crazy weird.

      Install the golang-go package instead, just as for Ubuntu sudo apt install golang-go.

Leave a Comment

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

*