I really love the Go programming language, it feels like a mix of the best of Java and Python put together. But I found that setting a Go development environment can be slightly tricky, mostly in figuring out how to set up the proper path variables.

Here, I provide a short guide on how to set up a Go development environment with Sublime Text 3 on Ubuntu/Linux. I hope it saves you (and my future-self) time when installing, updating, or re-installing the development environment.

Installing / Updating Go

If you’re updating a previously installed Go version, you must first delete the older one:

sudo rm -r /usr/local/go

Download the latest version of Go archive from and extract it:

sudo tar -C /usr/local -xzf go1.7.1.linux-amd64.tar.gz

Note: some people use the Go version manager (GVM) to install and set up Go, a tool similar to NVM which I highly recommend for Node.js, but for Go I prefer to set up everything myself.

Next, set the PATH environment variables by adding the following to .bashrc:

export PATH=$PATH:/usr/local/go/bin
export GOPATH=$HOME/go

Here I use home/alexeyza/go as my workspace (which is $HOME/go), but feel free to change it according to your preference.

And, create your workspace:

mkdir -p ~/go/src/

Setting up Sublime Text

Sublime text is my editor of choice for many things, and I highly recommend it for Go. If you don’t have it installed, start by installing Sublime Text 3, and installing the Package Control plugin.

Install GoSublime through package control (CTRL+Shift+P). It’s a Sublime Text plugin that provides Go code completion and other IDE-like features.

Next, set up the PATH environment variables for Sublime Text. This setting has slightly changed over time (which is why you may find different instruction variations online), but my current set up works with the following settings in Preferences -> Package Settings -> GoSublime -> Settings-User.
Make sure the GOPATH matches the path configured earlier.

    "env": {
        "GOPATH": "$HOME/go",
        "GOROOT": "/usr/local/go"

Now, save and restart Sublime Text. When you first restart Sublime Text after installing GoSublime, it may take a few seconds to install and set up MarGo.

Building and Running Go code

You can build, compile, and run your code directly from Sublime Text. Use CTRL+B or CTRL+9 like so:

Compiling and running within Sublime Text example

For additional help, type # help in the Sublime Text console.

Useful Go Plugins

Popular Go plugins that work well with GoSublime are GoOracle, GoImports, and GoDoc.

You can install them with:

go get -u
go get -u
go get -u

Read more here on how to configure these plugins to work with GoSublime.

Programming with Go

A great starting point is the Introduction to Programming in Go book by Caleb Doxsey, and the JustForFunc: Programming in Go channel on YouTube.

Update: An Up and Coming Go IDE

There is a new and cool looking Go IDE, Gogland, created by Jetbrains (the company behind the awesome IntelliJ and PyCharm). Check out the early build on their website.

Blog Logo

Alexey Zagalsky



Alexey Zagalsky

Software Engineering Researcher

Back to Overview