Subscribe to the Ardan Labs Insider

You’ll get our FREE Video Series & special offers on upcoming training events along with notifications on our latest blog posts.

Included in your subscription
  • Access to our free video previews
  • Updates on our latest blog posts
  • Discounts on upcoming events

Valid email required.

Submit failed. Try again or message us directly at

Thank You for Subscribing

Check your email for confirmation.

Installing Go And Your Workspace

Author image
William Kennedy


If you are new to Linux or the Mac you might find installing Go to be a bit confusing. It was for me when I started learning Go. Go was the reason I stopped using Windows, which I used for 20 years. Even if you’re experienced with these operation systems, setting up Go might seem a bit of a mystery. With this in mind, let’s walk through installing Go.

Downloading Go

Start by navigating to the Go download page:

Select the binary distribution for your operating system and run the installation program. After you run the installation program, Go will be installed at the following locations:

Mac: /usr/local/go
Windows: c:\go
Linux: $HOME/go

Note: If you download the tar.gz file for Linux, unzip the file in your $HOME directory under a folder named go. This is the expected and default location. Make sure the $HOME/go/bin folder is in your path.

Once Go is installed you should be able to run the go command from a terminal. Start by running the go env command:

$ go env

GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/_v/4r515ktx08g5yr6dgkxhfyfr0000gn/T/go-build802577064=/tmp/go-build -gno-record-gcc-switches -fno-common"

What you should notice is that the $GOPATH variable is empty. We need to fix this, but to fix it we need to understand what a Go workspace is.

Go Workspace

A Go workspace is a physical location on disk where you will load and work with Go code. I recommend that you maintain a single workspace on your machine. It will be simpler and most editor plugins are easier to configure as well.

Note: There are ways with most editors to create different configurations that could be used to point to different workspaces. So it is not impossible to have multiple workspaces, but I find it is better to maintain a single workspace.

Your Go workspace can’t be the same location that Go was installed in. So for Window and Linux users, please stay away from the c:\go and $HOME/go folders respectively. For Mac users, you would really need to go out of your way to use /usr/local/go but stay away from this location as well.

We need to create a new set of folders to represent the Go workspace. There is a special folder that must exist inside your Go workspace named src and is very important. All the code you load and work on must exist inside this src folder.

The src folder represents the start of your Go workspace. Your GOPATH is an environment variable that points to your Go workspace and represents the physical location on disk where the src folder is located, but does not include the src folder.

Mac and Linux Users

Create folders named code/go/src in your $HOME folder:

cd $HOME
mkdir -p ~/code/go/src

Update the .bash_profile file or your shell profile if there is another one you use:

cd $HOME
nano .bash_profile

At the top of the .bash_profile add these environmental variables:

export GOPATH="$HOME/code/go"
export PATH="$PATH:$GOPATH/bin"

Save the file and then source it:

source .bash_profile

Window Users

Create folders named code\go\src in your $HOME folder:

cd c:\Users\<username>
md code

cd code
md go

cd go
md src

Go to your system settings and add the GOPATH variable and update your PATH.


Then close all terminal windows and open a new one.

Validating Go Workspace

Validate that to Go workspace is configured correctly by running the go env command again:

$ go env

GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/_v/4r515ktx08g5yr6dgkxhfyfr0000gn/T/go-build802577064=/tmp/go-build -gno-record-gcc-switches -fno-common"

If everything is good, the GOPATH variable will no longer be empty. If the GOPATH variable is still empty, try one more time to create a new terminal window. If still no luck, reach out to me over email:

At this point Go is installed and you are ready to write some code. To test this do two things. First, go get the Go linter named golint:

Note: You must have the git client installed and installed to work on the command line. If not then go get will not work.

go get -u

If everything works you should see no response. What go get does is clone the golint repo and places the source code inside the Go workspace. It also builds the code and installs the golint binary inside the newly created bin folder inside the Go workspace.

cd $GOPATH/src/
ls -la

total 144
drwxr-xr-x  13 bill  staff    442 May 12 21:52 .
drwxr-xr-x   4 bill  staff    136 Nov 16 18:16 ..
drwxr-xr-x  15 bill  staff    510 May 12 21:59 .git
-rw-r--r--   1 bill  staff     96 May 12 21:52 .travis.yml
-rw-r--r--   1 bill  staff    410 Aug  7  2015
-rw-r--r--   1 bill  staff   1479 Aug  7  2015 LICENSE
-rw-r--r--   1 bill  staff   3098 May 12 21:52
drwxr-xr-x   4 bill  staff    136 May 12 21:52 golint
-rw-r--r--   1 bill  staff  43808 May 12 21:52 lint.go
-rw-r--r--   1 bill  staff    487 May 12 21:52 lint16.go
-rw-r--r--   1 bill  staff   7607 May 12 21:52 lint_test.go
drwxr-xr-x   4 bill  staff    136 Aug  7  2015 misc
drwxr-xr-x  32 bill  staff   1088 May 12 21:52 testdata

Notice that URL path of golint used in the go get call is represented on disk. The source code was loaded inside the Go workspace, based on the configured GOPATH, inside the src folder.

To validate the bin folder was configured properly with your system PATH, try to run the golint command:

$ golint --help
Usage of golint:
	golint [flags] # runs on package in current directory
	golint [flags] package
	golint [flags] directory
	golint [flags] files... # must be a single package
  -min_confidence float
    	minimum confidence of a problem to print it (default 0.8)
    	set exit status to 1 if any issues are found

If everything is good you should see that help output.


There are a lot of options and plugins for many of the popular editors.


Victor Farazdagi wrote this post on installing Vim for Go:

Visual Studio Code

Luke Hobah wrote an amazing plugin for VS Code:


Joe Fitzgerald wrote this plugin for Atom


This is the configuration Guillaume Charmes uses:


I hope this installation guide get you up and running quickly. Now that you can start writing code in Go, check out some of these other resources.

Ardan Labs Go Training

Offical Go Resources

Dave Cheney


Go In Action
If you would like to try out the book, send me an email:

Slack and Forum Community

Go Training

We have taught Go to thousands of developers all around the world since 2014. There is no other company that has been doing it longer and our material has proven to help jump start developers 6 to 12 months ahead of their knowledge of Go. We know what knowledge developers need in order to be productive and efficient when writing software in Go.

Our classes are perfect for both experienced and beginning engineers. We start every class from the beginning and get very detailed about the internals, mechanics, specification, guidelines, best practices and design philosophies. We cover a lot about "if performance matters" with a focus on mechanical sympathy, data oriented design, decoupling and writing production software.

Capital One
Red Ventures

Interested in Ultimate Go Corporate Training and special pricing?

Let’s Talk Corporate Training!

Join Our Online
Education Program

Our courses have been designed from training over 30,000 engineers since 2013, and they go beyond just being a language course. Our goal is to challenge every student to think about what they are doing and why.