$GOOS $GOARCH darwin 386 darwin amd64 dragonfly 386 dragonfly amd64 freebsd 386 freebsd amd64 freebsd arm linux 386 linux amd64 linux arm netbsd 386 netbsd amd64 netbsd arm openbsd 386 openbsd amd64 plan9 386 plan9 amd64 solaris amd64 windows 386 windows amd64
The hard way
git clone https://go.googlesource.com/go
cd go/
git checkout go1.4.2
cd src/
./all.bash
# 64 bit OSX
GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 ./make.bash
# 32 Bit Windows
GOOS=windows GOARCH=386 CGO_ENABLED=1 ./make.bash
# Raspberry Pi
GOOS=linux GOARCH=arm GOARM=5 CGO_ENABLED=1 ./make.bash
$ ls ../bin/
darwin_amd64 linux_arm windows_386 go gofmt
package main
import (
"fmt"
"os/user"
)
func main() {
// Get Current User
currentUser, err := user.Current()
if err != nil {
fmt.Println("Error: " + err.Error())
}
fmt.Println("My home dir is: " + currentUser.HomeDir)
}
go build sampleApp.go
GOOS="windows" GOARCH="386" ./go/bin/go build sampleApp.go
gox -build-toolchain
gox -osarch="darwin/amd64 linux/amd64 windows/amd64"