Dec 23, 2014
I’ve had to do this more than once recently, so I figured I’d document the simple steps for setting up the Go programming language on Windows. Most of this is simple and straightforward. The only tricky part I found is setting up your GOPATH, which defines a convention for storing and building Go code you write and acquire from open source code repositories.
Follow these five simple steps to install Go.
To make things simple, use the default installation path at C:\Go
C:\Go\bin
) are in your Path
system environment variables. To check click System
, Advanced system settings
, Environment Variables...
and open Path
under System variables
:
An easy way to confirm is to open the command line and type go version
:
C:\Projects\Go
folder as my root Go workspace:
System
, Advanced system settings
, Environment Variables...
and click New...
under System variables
:
Set the variable name to GOPATH
and value to your Go workspace path (e.g. C:\Projects\Go
):
You can quickly check to ensure your path has been set by opening the command line and typing echo %GOPATH%
and check the output:
And that’s all it takes! You’re ready to get started.
Want to quickly test and ensure this is all working as expected? Open the command line and type the following:
go get github.com/golang/example/hello
%GOPATH%/bin/hello
You should see the output as “Hello, Go examples!” (refreshingly, not your typical hello world):
I hope this helps!