2011-01-05 At 12:15 AM
Go on windows tutorial (#golang)
Recently I invested some time to learn about new and popular language Go. I wanna give a test-drive, and since I have Windows XP and there is no GO official windows Go port, I needed to do some manual work.
This is the procedure:
- download go windows port (mingw) from http://code.google.com/p/gomingw/downloads/detail?name=gowin32_2010-12-22.zip&can=2&q=
- unzip to some folder. I did this in c:\testing\go, so I have c:\testing\go\bin\8g.exe
- create batch file set-go.bat and put it in the folder that is in sys path, e.g. c:\windows\system32\set-go.bat:
@echo off
set GOROOT=c:\testing\go
set GOOS=windows
set GOARCH=386
SET PATH=%GOROOT%\bin;%PATH%
echo Set GOROOT=%GOROOT%
Start GO env. shell:
- start DOS prompt, e.g. start/run/cmd
- call set-go
Someone could ask why I didn’t put these vars to global system path (my computer right click, props, env. vars …). The answer is: I don’t do things like this, I like having more control over my shell environment. If you want to set it globally - check this link.
Now environment is ready, and I can write go programs, compile and run them like this:
- create new file hello.go
package main
func main() {
println(“Hello world.”)
}
- go to the folder in your DOS-GO prompt and compile it - output is in hello.8:
8g hello.go
- link it - output is in hello.exe
8l -o hello.exe hello.8
- run it:
> hello.exe
Hello world.
Additional notes:
- Go dev team is developing official windows port - so stay tuned
- On http://stackoverflow.com/questions/1717652/can-go-compiler-be-installed-on-windows you can find other useful information and similar tutorial.
Good luck Go-ing!

:

