Monday, July 14, 2014

Golang windows, a complete setup guide

1) download ZIP
Get the latest code from: http://golang.org/dl/

2) extract ZIP
Extract zip to example C:\local\dev\go

3) create a gopath directory,
- Gopath path is where third parties will be stored. Example if you will execute a "go get github.com/somelib", this library will be stored in gopath.
Create a c:\local\dev\gopath

4) set the environmental variables
open System Properties->Advanced->Environmental Variables

GOROOT=C:\local\dev\go
GOBIN=%GOROOT%\bin
GOPATH=c:\local\dev\gopath

5) add your gobin to PATH
append C:\local\dev\go\bin to PATH

6) test
6.1) create the path "C:\local\dev\gopath\src\myfirstproject"
6.2) create the main.go file "C:\local\dev\gopath\src\myfirstproject\main.go"
 package main  
 import "fmt"  
 func main() {  
   fmt.Println("Hi foobar")  
 }  

6.2) you can now build the project anywhere example,
6.2.1) open cmd.exe
6.2.2) cd c:\temp
6.2.3) go build myfirstproject
6.2.4) run myfirstproject.exe

7) get a few libraries
7.1) you can download some free git, svn, and hg for windows
7.2) once you have them you can now do "go get -u github.com/somelib"

8) get a IDE
download liteide

congrats!