Decentralized Application

Architecture & Development

Programming

Setting up Go development environment

Go is fast growing programming language, so I thought it would be helpful to show how to setup and run Go programs on your machine. The instruction is for Mac OS X. Homebrew is required. If you don't have home-brew in your local environment, follow this link to setup home brew in your Mac development environment.
https://brew.sh/

$ brew install go

In order to run Go within your terminal, you’ll need to setup the GOPATH environment variable. This will allow Go to properly locate your workspace in order to run your code and manage your packages. I have my workspace "code" inside my home directory. ($HOME/code") and or Golang I have in $HOME/code/go. I'm using bash profile to setup GOPATH.

1. Edit ~/.bash_profile.
2. Add following lines to bash_profile

export GOPATH="$HOME/code/go"
export GOROOT=/usr/local/opt/go/libexec
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

3. I.e. source .bash_profile file or close and open terminal.
$ source ~/.bash_profile

After the setup when you type go you should see as below.

gorun