How portable is Go

Unfortunately, for the performance concern, Go will compile your source code into binary code targeted at your platform. In this sense Go is not portable. However, it does allow cross-platofrm compilation for different architecture and operating systems [1] using the same source code on the same machine.

When specified the build flag in the build command, Go will produce binary code for the specific OS. The following is an example about how to build a linux and OS X binary [2].

// +build linux,cgo darwin,cgo

[1] https://golang.org/pkg/go/build/

[2] https://golang.org/pkg/go/build/#hdr-Build_Constraints