Go Developing for Multiple Platforms with Conditional Compiling Build tags

30% OFF - 9th Anniversary discount on Entity Framework Extensions until December 15 with code: ZZZANNIVERSARY9


// +build linux

package lib

var OnlyAccessibleInLinux int // Will only be compiled in Linux

Negate a platform by placing ! before it:

// +build !windows

package lib

var NotWindows int // Will be compiled in all platforms but not Windows

List of platforms can be specified by separating them with spaces

// +build linux darwin plan9

package lib

var SomeUnix int // Will be compiled in linux, darwin and plan9 but not on others

Got any Go Question?