BuildConstraintExpression
Go allows to specify so-called build constraints on files, to specify conditions on which they should be built (or not).
For example, the following build constraint specifies that the file is either built on linux and darwin arm-based machines:
//go:build (linux && arm64) || (darwin && arm64)
These build constraints consist of several expressions (tags) that can be combined with ||
and &&
as well as negated with !
.
This interface serves as the bases for all these expressions and contains a companion object to parse such an expression (without the //go:build
prefix) using fromString.
Inheritors
Functions
Evaluates whether the current expression satisfies the set of tags. Tags can be for example the target operating system (e.g., linux
), the target architecture (e.g. arm64
), the Go version (e.g. go1.20
) or other custom tags supplied to the build process.