go1.20.5
GoThrough

constraint.Expr

// An Expr is a build tag constraint expression. // The underlying concrete type is *AndExpr, *OrExpr, *NotExpr, or *TagExpr. type Expr interface { // String returns the string form of the expression, // using the boolean syntax used in //go:build lines. String() string // Eval reports whether the expression evaluates to true. // It calls ok(tag) as needed to find out whether a given build tag // is satisfied by the current build configuration. Eval(ok func(tag string) bool) bool }

constraint.IsGoBuild

// IsGoBuild reports whether the line of text is a “//go:build” constraint. // It only checks the prefix of the text, not that the expression itself parses. func IsGoBuild(line string) bool

constraint.IsPlusBuild

// IsPlusBuild reports whether the line of text is a “// +build” constraint. // It only checks the prefix of the text, not that the expression itself parses. func IsPlusBuild(line string) bool

constraint.Parse

// Parse parses a single build constraint line of the form “//go:build ...” or “// +build ...” // and returns the corresponding boolean expression. func Parse(line string) (Expr, error)

constraint.PlusBuildLines

// PlusBuildLines returns a sequence of “// +build” lines that evaluate to the build expression x. // If the expression is too complex to convert directly to “// +build” lines, PlusBuildLines returns an error. func PlusBuildLines(x Expr) ([]string, error)