Tutorial by Examples

// +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 separa...
If you name your file lib_linux.go, all the content in that file will only be compiled in linux environments: package lib var OnlyCompiledInLinux string
Different platforms can have separate implementations of the same method. This example also illustrates how build tags and file suffixes can be used together. File main.go: package main import "fmt" func main() { fmt.Println("Hello World from Conditional Compilation Doc!&...

Page 1 of 1