構建標籤

// +build linux

package lib

var OnlyAccessibleInLinux int // Will only be compiled in Linux

通過在其前面放置 ! 來取消平臺:

// +build !windows

package lib

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

可以通過用空格分隔來指定平臺列表

// +build linux darwin plan9

package lib

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