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 operating systems, architectures, and TinyGo board configurations.
How deep it goes
Explains file syntax, command-line tags, negation, Boolean combinations, and a target specification.
Examples
Uses Arduino Nano 33 IoT pin mappings, a TinyGo target configuration, and operating-system constraint expressions.
What you can do after
Operate/configure Go or TinyGo builds with tags and write constraints for selecting files.

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 →

Also covered in

What to know first

Related concepts

Questions about build tag

What is build tag?

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

Which Manning books explain build tag?

Learn Go with Pocket-Sized Projects, 100 Go Mistakes and How to Avoid Them and Go in Practice, Second Edition.

What should I know before learning build tag?

Manning books that teach build tag usually introduce Go and integration test first.

What is the difference between build tag and short mode?

A build tag is a Go source-file constraint that determines whether a file is included in a particular build configuration. Short mode is a test-execution mode in which tests can detect that they should omit long-running or integration-oriented work.

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.