A build tag is a source-file constraint that tells the Go toolchain whether to include a file for a particular build environment. Place the special comment at the start of the file and follow it with a blank line. section 12.4.2
Use build tags and environment-specific filenames to keep platform differences behind separate implementations:
- Use tags such as !windows or !linux,!darwin to exclude files from selected operating systems. section 12.4.2
- Relate tag values to GOOS and GOARCH settings when compiling for different operating systems and architectures. section 12.4.2
- Name files with suffixes such as foo_windows.go or foo_386.go to select platform- or architecture-specific code without an explicit tag. section 12.4.2
$ GOOS=windows GOARCH=386 go build
Cross-compile a 386 Windows build by setting GOOS and GOARCH before running go build. section 12.4.2


