January 17, 2015
Some notes on how to setup the computer to get started with 
go language. Very simple notes. 
Installation notes for Mac are at the end
On Windows
- 
Installed it via the msi installer from the downloads page
- 
Open the command line (cmd.exe) and check everything is fine
 
> go version
 go version go1.4 windows/386
 
 Go installer sets upGOROOT(although I think it is not needed to define it explicitly since the go tool can find it)
 
> echo %GOROOT%
C:\Go\
 We can also check other variables
 
> go env GOOS
windows
> go env GOARCH
386
 
 
- 
The only environment variable that needs to be set is GOPATH
 
 AddGOPATHas a new User Environment Variable, its value should be somewhere we are going to put all our go code, also it should not be the same asGOROOT.
> echo %GOPATH%
C:\Users\GuillermoIgnacio\Documents\go
 As explained in the docs,GOPATHdirectory needs to have 3 directories in it:src,pkgandbin
cd %GOPATH%
mkdir src
mkdir pkg
mkdir bin
 
- 
Optionally, we could add GOPATH\binto ourPATHso we can run executables easier after each time we use the install command:go install something
On Mac OS X
- Install it via homebrew
brew install go
 
- 
Create a workspace. (The workspace is a directory with 3 subdirectories src,pkgandbin) so we can set$GOPATHvariable in the next step. I created inside~/Documentsdirectory
cd ~/Documents
mkdir goworkspace
cd goworkspace
mkdir src
mkdir pkg
mkdir bin
 
- 
Set $GOPATHin~/.bash_profile. Optionally we can addbin
# Go stuff                                                                                                          
export GOPATH="${HOME}/Documents/goworkspace"
export PATH=$PATH:"${GOPATH}/bin"
- 
Also get go vetandgo doc
go get golang.org/x/tools/cmd/vet
go get golang.org/x/tools/cmd/godoc
 
Done!. Now I am ready to start with 
hello world or 
a little library :)
 
 
  
0 comments :
Post a Comment