Namespace: go.std.go.build.constraint
v1.0Contents
Summary
Provides a low-level interface to the go/build/constraint package.
Package constraint implements parsing and evaluation of build constraint lines.
See https://golang.org/cmd/go/#hdr-Build_constraints for documentation about build constraints themselves.
This package parses both the original “// +build” syntax and the “//go:build” syntax that was added in Go 1.17.
See https://golang.org/design/draft-gobuild for details about the “//go:build” syntax.
Index
- *AndExpr
- *NotExpr
- *OrExpr
- *SyntaxError
- *TagExpr
- AndExpr
- Expr
- IsGoBuild
- IsPlusBuild
- NotExpr
- OrExpr
- Parse
- PlusBuildLines
- SyntaxError
- TagExpr
- arrayOfAndExpr
- arrayOfExpr
- arrayOfNotExpr
- arrayOfOrExpr
- arrayOfSyntaxError
- arrayOfTagExpr
Legend
-
Constant
Variable
Function
Macro
Special form
Type
GoVar
Receiver/Method
Constants
Constants are variables with :const true in their metadata. Joker currently does not recognize them as special; as such, it allows redefining them or their values.-
(None.)
Variables
-
(None.)
Functions, Macros, and Special Forms
-
IsGoBuild
Function v1.0(IsGoBuild line)
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.
Go input arguments: (line string)
Go returns: bool
Joker input arguments: [^String line]
Joker returns: ^Boolean -
IsPlusBuild
Function v1.0(IsPlusBuild line)
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.
Go input arguments: (line string)
Go returns: bool
Joker input arguments: [^String line]
Joker returns: ^Boolean -
Parse
Function v1.0(Parse line)
Parse parses a single build constraint line of the form “//go:build ...” or “// +build ...”
and returns the corresponding boolean expression.
Go input arguments: (line string)
Go returns: (Expr, error)
Joker input arguments: [^String line]
Joker returns: [^Expr, ^Error] -
PlusBuildLines
Function v1.0(PlusBuildLines x)
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.
Go input arguments: (x Expr)
Go returns: ([]string, error)
Joker input arguments: [^Expr x]
Joker returns: [^arrayOfString, ^Error]
Types
-
*AndExpr
Concrete Type v1.0An AndExpr represents the expression X && Y.
-
String
Receiver for *AndExpr v1.0([])
-
*NotExpr
Concrete Type v1.0A NotExpr represents the expression !X (the negation of X).
-
String
Receiver for *NotExpr v1.0([])
-
*OrExpr
Concrete Type v1.0An OrExpr represents the expression X || Y.
-
String
Receiver for *OrExpr v1.0([])
-
*SyntaxError
Concrete Type v1.0A SyntaxError reports a syntax error in a parsed build expression.
-
Error
Receiver for *SyntaxError v1.0([])
-
*TagExpr
Concrete Type v1.0A TagExpr is an Expr for the single tag Tag.
-
String
Receiver for *TagExpr v1.0([])
-
AndExpr
Concrete Type v1.0An AndExpr represents the expression X && Y.
-
Expr
Abstract Type v1.0An Expr is a build tag constraint expression.
The underlying concrete type is *AndExpr, *OrExpr, *NotExpr, or *TagExpr.
-
String
Method for Expr v1.0([])
-
NotExpr
Concrete Type v1.0A NotExpr represents the expression !X (the negation of X).
-
OrExpr
Concrete Type v1.0An OrExpr represents the expression X || Y.
-
SyntaxError
Concrete Type v1.0A SyntaxError reports a syntax error in a parsed build expression.
-
TagExpr
Concrete Type v1.0A TagExpr is an Expr for the single tag Tag.
-
arrayOfAndExpr
Concrete Type v1.0An AndExpr represents the expression X && Y.
-
arrayOfExpr
Concrete Type v1.0An Expr is a build tag constraint expression.
The underlying concrete type is *AndExpr, *OrExpr, *NotExpr, or *TagExpr.
-
arrayOfNotExpr
Concrete Type v1.0A NotExpr represents the expression !X (the negation of X).
-
arrayOfOrExpr
Concrete Type v1.0An OrExpr represents the expression X || Y.
-
arrayOfSyntaxError
Concrete Type v1.0A SyntaxError reports a syntax error in a parsed build expression.
-
arrayOfTagExpr
Concrete Type v1.0A TagExpr is an Expr for the single tag Tag.