When you have to "go get" and "set path" multiple times

On Windows, when you install Golang the installer will normally set an environment variable named GOROOT. GOROOT is a variable that points to the location of go.

However you also need to set GOPATH, this is especially important when you start installing external libraries and packages via the go get command.

You can verify that GOPATH is not set by looking at the system variables window
and seeing that GOPATH is not listed.

To set the GOPATH in Windows

  1. Open System Properties by opening Explorer and then navigating to My Computer. Then click on System Properties.
  2. Click on the button labeled Environment Variables
  3. Click on the button labeled New...
  4. Add GOPATH as the variable name and set the variable value to C:\Go\src (assuming default Go installation on Windows).
  5. Click on the button labeled 'OK' and then verify GOPATH is set.

Daniel Tse

Read more posts by this author.

Subscribe to Daniel Tse, Engineer, Consultant

Get the latest posts delivered right to your inbox.

or subscribe via RSS with Feedly!