- Install Homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew update
- Install GO
brew install go
- Create a directory workspace in home folder
mkdir workspace
- Setup GOPATH and GOROOT
cd workspace
export GOPATH=/Users/`whoami`/workspace
- Download latest GO from Here
wget https://storage.googleapis.com/golang/go1.9.linux-amd64.tar.gz
tar -C /usr/local -xzf go1.9.linux-amd64.tar.gz
- Set GOPATH and PATH
cd
mkdir -p ~/workspace; echo "export GOPATH=$HOME/workspace" >> ~/.bashrc
echo "export PATH=$PATH:$HOME/workspace/bin:/usr/local/go/bin" >> ~/.bashrc
source ~/.bashrc
- Donwload and install lates MSI distributable from https://golang.org/dl/
- create a directory workspace in C:\
- To make life simple use the default installation path at C:\workspace
- The installer should put the C:\workspace\bin directory in your PATH environment variable.
- A workspace is a directory hierarchy with three directories at its root:
src
contains Go source files,pkg
contains package objects, andbin
contains executable commands.
If your code in a source repository somewhere. then you should use the root of that source repository as your base path inside src
.
For instance, if you have a bitbucket account at bitbucket.org/user, that should be your base path.
mkdir -p $GOPATH/src/bitbucket.org/user
To Run a simple program, first choose a package path (bitbucket.org/user/hello)
mkdir $GOPATH/src/bitbucket.org/user/hello
where hello is a package directory inside base path. and then create your first hello program (hello.go) inside package.
###Compile and Run
go install $GOPATH/src/bitbucket.org/user/hello
$GOPATH/bin/hello
- Install an IDE https://www.jetbrains.com/idea/
its really helpfull