Go dev env

Starting Go development requires the installation of the Go binaries as well as setting up the development environment.


Install Go

Download the Go binaries and follow the installation routine.

Open a terminal and check if go was successfully installed.


Create workspace

To create a workspace, where you will keep all your Go projects, just add a folder anywhere on your filesystem and put inside a src and a bin folder. The src folder will keep 1..n repositories which will be tracked by Git. Every Git repository will contain 1..n packages composed from 1..n Go source files in a single directory. Straightforward right? It's easier to show it in a screenshot.

As you can see, there are two repositories tracked by git inside of com.chevronsix/training/go. Usually a Go workspace contains many source repositories who contain many packages and commands.


Set GOPATH

The GOPATH variable specifies the location of your workspace. To set a custom PATH have a look here. To afterwards check your variable just type go env GOPATH in your terminal. It will print the effective current GOPATH.

For convenience, add the workspace's bin subdirectory to your PATH:

$ export PATH=$PATH:$(go env GOPATH)/bin

You are now good to go to create your first program.