liveBook · Manning

Build tag

A build tag is a Go source-file constraint that determines whether a file is included in a particular build configuration.

How 3 Manning books explain it

Learn Go with Pocket-Sized Projects

A build tag is a source-file constraint that controls whether the file is included for a particular build configuration.

How it is used
Selects source files for particular board, operating-system, or architecture builds.
How deep it goes
Defines file placement and inclusion, then shows command-line selection, Boolean constraints, and target-supplied tags.
Examples
Uses an Arduino Nano 33 pin-mapping file, a TinyGo build command, and a target specification.
What you can do after
Operate/configure it by selecting board-specific files with `-tags` or a TinyGo target.

Read how Learn Go with Pocket-Sized Projects explains build tag →

100 Go Mistakes and How to Avoid Them

A build tag is a Go source-selection constraint that controls whether a file is included in a build or test invocation.

How it is used
Uses file-selection constraints to classify tests and conditionally include application sources.
How deep it goes
Explains placement, tag matching, negation, and command effects, but stops short of a full constraint-expression treatment.
Examples
Demonstrates cgo, integration, !integration, and !race constraints alongside go test commands and skipped-test output.
What you can do after
Operate/configure Go builds and tests by selecting files with tags and recognizing when untagged tests remain included.

Read how 100 Go Mistakes and How to Avoid Them explains build tag →

Go in Practice, Second Edition

A Go build tag is a source-file constraint that determines whether the file is included for a particular build environment.

How it is used
Selects platform-specific source files when building applications for different operating systems and architectures.
How deep it goes
Explains tag placement, exclusion values, GOOS and GOARCH linkage, and filename conventions.
Examples
Demonstrates !windows and !linux,!darwin tags, foo_windows.go and foo_386.go filenames, and a Windows 386 build command.
What you can do after
Operate/configure Go builds that include appropriate files for selected operating systems and hardware architectures.

Read how Go in Practice, Second Edition explains build tag →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.