Install Go in Ubuntu 18 using snap

This article describes how to install Go in Ubuntu 18 using the snap software and package management tool.

Go is an open source programming language that is quickly growing in popularity. You can discover more about Go at the official website:

Snap is described as “the app store for Linux”. See my other article getting started with snap for a quick introduction.

How to install Go 1.11.5 in Ubuntu 18 using snap

Snap is included in Ubuntu 18.04.2 LTS so you can start using it straight away.

Step 1: Check if Go is already installed

A common method of verifying if software is installed is to try print the version details. You can do this for Go using the go version command.

go version

If Go is not installed, you will get an error Command 'go' not found. Ubuntu also helpfully tells us that we can use snap to install it.

go version error

Step 2: Install Go using snap

This section describes how to install the latest stable version of Go using snap. At the time of writing, the latest stable version is Go 1.11.5

You can check the latest available version using snap info go.

snap info go

Note: the absense of a green check beside the publisher means they are not a verified publisher.

You can also find out more about this Go snap in the snap store:

Different versions of the snap are listed as channels.

snap info go

To install the latest stable version:

sudo snap install go

Alternatively, to specify a version to install, use the --channel= option, for example

snap install --channel=1.12/candidate go

Step 3: Classic confinement error

At this point you will get an error about classic confinement.

Explanation: Most snaps are installed in confined containers and only have limited access to other system resources. However, snaps published with classic confinement have greater access to the rest of the system, which is desirable for scripting packages such as Go.

snap classic confinement error

Run the install command again, but this time specify the --classic option.

sudo snap install go --classic

The snap will be downloaded and installed. This may take a few minutes depending on your internet connection.

snap install go

Step 4: Verify the install

You can verify the snap is successfully installed by using the list command to list all installed snaps:

snap list

The go snap will be listed.

snap list

The go command is now also available for use. Try the go version command again and this time you should see the Go version details printed:

go version

go version

Now check the go environment details with go env:

go env

An important environmental variable to note here is the GOPATH which specifies the path of your go workspace. The workspace is a directory where you organise your project source files and binaries. By default it will be set to $HOME/go. For example, mine is /home/codeooze/go.

You can read more about workspaces in the Go documentation:

go env


You have now successfully installed Go in Ubuntu 18 using snap.

For steps to change the GOPATH and run a simple “Hello, world” program please refer my other article install Go 1.11.5 in Ubuntu 18.