summaryrefslogtreecommitdiff
path: root/devdocs/go/go%2Fbuild%2Fconstraint%2Findex.html
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
committerCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
commit754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch)
treef1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/go/go%2Fbuild%2Fconstraint%2Findex.html
new repository
Diffstat (limited to 'devdocs/go/go%2Fbuild%2Fconstraint%2Findex.html')
-rw-r--r--devdocs/go/go%2Fbuild%2Fconstraint%2Findex.html88
1 files changed, 88 insertions, 0 deletions
diff --git a/devdocs/go/go%2Fbuild%2Fconstraint%2Findex.html b/devdocs/go/go%2Fbuild%2Fconstraint%2Findex.html
new file mode 100644
index 00000000..1a648460
--- /dev/null
+++ b/devdocs/go/go%2Fbuild%2Fconstraint%2Findex.html
@@ -0,0 +1,88 @@
+<h1> Package constraint </h1> <ul id="short-nav">
+<li><code>import "go/build/constraint"</code></li>
+<li><a href="#pkg-overview" class="overviewLink">Overview</a></li>
+<li><a href="#pkg-index" class="indexLink">Index</a></li>
+</ul> <h2 id="pkg-overview">Overview </h2> <p>Package constraint implements parsing and evaluation of build constraint lines. See <a href="https://golang.org/cmd/go/#hdr-Build_constraints">https://golang.org/cmd/go/#hdr-Build_constraints</a> for documentation about build constraints themselves. </p>
+<p>This package parses both the original “// +build” syntax and the “//go:build” syntax that was added in Go 1.17. See <a href="https://golang.org/design/draft-gobuild">https://golang.org/design/draft-gobuild</a> for details about the “//go:build” syntax. </p> <h2 id="pkg-index">Index </h2> <ul id="manual-nav">
+<li><a href="#GoVersion">func GoVersion(x Expr) string</a></li>
+<li><a href="#IsGoBuild">func IsGoBuild(line string) bool</a></li>
+<li><a href="#IsPlusBuild">func IsPlusBuild(line string) bool</a></li>
+<li><a href="#PlusBuildLines">func PlusBuildLines(x Expr) ([]string, error)</a></li>
+<li><a href="#AndExpr">type AndExpr</a></li>
+<li> <a href="#AndExpr.Eval">func (x *AndExpr) Eval(ok func(tag string) bool) bool</a>
+</li>
+<li> <a href="#AndExpr.String">func (x *AndExpr) String() string</a>
+</li>
+<li><a href="#Expr">type Expr</a></li>
+<li> <a href="#Parse">func Parse(line string) (Expr, error)</a>
+</li>
+<li><a href="#NotExpr">type NotExpr</a></li>
+<li> <a href="#NotExpr.Eval">func (x *NotExpr) Eval(ok func(tag string) bool) bool</a>
+</li>
+<li> <a href="#NotExpr.String">func (x *NotExpr) String() string</a>
+</li>
+<li><a href="#OrExpr">type OrExpr</a></li>
+<li> <a href="#OrExpr.Eval">func (x *OrExpr) Eval(ok func(tag string) bool) bool</a>
+</li>
+<li> <a href="#OrExpr.String">func (x *OrExpr) String() string</a>
+</li>
+<li><a href="#SyntaxError">type SyntaxError</a></li>
+<li> <a href="#SyntaxError.Error">func (e *SyntaxError) Error() string</a>
+</li>
+<li><a href="#TagExpr">type TagExpr</a></li>
+<li> <a href="#TagExpr.Eval">func (x *TagExpr) Eval(ok func(tag string) bool) bool</a>
+</li>
+<li> <a href="#TagExpr.String">func (x *TagExpr) String() string</a>
+</li>
+</ul> <h3>Package files</h3> <p> <span>expr.go</span> <span>vers.go</span> </p> <h2 id="GoVersion">func <span>GoVersion</span> <span title="Added in Go 1.21">1.21</span> </h2> <pre data-language="go">func GoVersion(x Expr) string</pre> <p>GoVersion returns the minimum Go version implied by a given build expression. If the expression can be satisfied without any Go version tags, GoVersion returns an empty string. </p>
+<p>For example: </p>
+<pre data-language="go">GoVersion(linux &amp;&amp; go1.22) = "go1.22"
+GoVersion((linux &amp;&amp; go1.22) || (windows &amp;&amp; go1.20)) = "go1.20" =&gt; go1.20
+GoVersion(linux) = ""
+GoVersion(linux || (windows &amp;&amp; go1.22)) = ""
+GoVersion(!go1.22) = ""
+</pre> <p>GoVersion assumes that any tag or negated tag may independently be true, so that its analysis can be purely structural, without SAT solving. “Impossible” subexpressions may therefore affect the result. </p>
+<p>For example: </p>
+<pre data-language="go">GoVersion((linux &amp;&amp; !linux &amp;&amp; go1.20) || go1.21) = "go1.20"
+</pre> <h2 id="IsGoBuild">func <span>IsGoBuild</span> <span title="Added in Go 1.16">1.16</span> </h2> <pre data-language="go">func IsGoBuild(line string) bool</pre> <p>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. </p>
+<h2 id="IsPlusBuild">func <span>IsPlusBuild</span> <span title="Added in Go 1.16">1.16</span> </h2> <pre data-language="go">func IsPlusBuild(line string) bool</pre> <p>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. </p>
+<h2 id="PlusBuildLines">func <span>PlusBuildLines</span> <span title="Added in Go 1.16">1.16</span> </h2> <pre data-language="go">func PlusBuildLines(x Expr) ([]string, error)</pre> <p>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. </p>
+<h2 id="AndExpr">type <span>AndExpr</span> <span title="Added in Go 1.16">1.16</span> </h2> <p>An AndExpr represents the expression X &amp;&amp; Y. </p>
+<pre data-language="go">type AndExpr struct {
+ X, Y Expr
+}
+</pre> <h3 id="AndExpr.Eval">func (*AndExpr) <span>Eval</span> <span title="Added in Go 1.16">1.16</span> </h3> <pre data-language="go">func (x *AndExpr) Eval(ok func(tag string) bool) bool</pre> <h3 id="AndExpr.String">func (*AndExpr) <span>String</span> <span title="Added in Go 1.16">1.16</span> </h3> <pre data-language="go">func (x *AndExpr) String() string</pre> <h2 id="Expr">type <span>Expr</span> <span title="Added in Go 1.16">1.16</span> </h2> <p>An Expr is a build tag constraint expression. The underlying concrete type is *<a href="#AndExpr">AndExpr</a>, *<a href="#OrExpr">OrExpr</a>, *<a href="#NotExpr">NotExpr</a>, or *<a href="#TagExpr">TagExpr</a>. </p>
+<pre data-language="go">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
+ // contains filtered or unexported methods
+}</pre> <h3 id="Parse">func <span>Parse</span> <span title="Added in Go 1.16">1.16</span> </h3> <pre data-language="go">func Parse(line string) (Expr, error)</pre> <p>Parse parses a single build constraint line of the form “//go:build ...” or “// +build ...” and returns the corresponding boolean expression. </p>
+<h2 id="NotExpr">type <span>NotExpr</span> <span title="Added in Go 1.16">1.16</span> </h2> <p>A NotExpr represents the expression !X (the negation of X). </p>
+<pre data-language="go">type NotExpr struct {
+ X Expr
+}
+</pre> <h3 id="NotExpr.Eval">func (*NotExpr) <span>Eval</span> <span title="Added in Go 1.16">1.16</span> </h3> <pre data-language="go">func (x *NotExpr) Eval(ok func(tag string) bool) bool</pre> <h3 id="NotExpr.String">func (*NotExpr) <span>String</span> <span title="Added in Go 1.16">1.16</span> </h3> <pre data-language="go">func (x *NotExpr) String() string</pre> <h2 id="OrExpr">type <span>OrExpr</span> <span title="Added in Go 1.16">1.16</span> </h2> <p>An OrExpr represents the expression X || Y. </p>
+<pre data-language="go">type OrExpr struct {
+ X, Y Expr
+}
+</pre> <h3 id="OrExpr.Eval">func (*OrExpr) <span>Eval</span> <span title="Added in Go 1.16">1.16</span> </h3> <pre data-language="go">func (x *OrExpr) Eval(ok func(tag string) bool) bool</pre> <h3 id="OrExpr.String">func (*OrExpr) <span>String</span> <span title="Added in Go 1.16">1.16</span> </h3> <pre data-language="go">func (x *OrExpr) String() string</pre> <h2 id="SyntaxError">type <span>SyntaxError</span> <span title="Added in Go 1.16">1.16</span> </h2> <p>A SyntaxError reports a syntax error in a parsed build expression. </p>
+<pre data-language="go">type SyntaxError struct {
+ Offset int // byte offset in input where error was detected
+ Err string // description of error
+}
+</pre> <h3 id="SyntaxError.Error">func (*SyntaxError) <span>Error</span> <span title="Added in Go 1.16">1.16</span> </h3> <pre data-language="go">func (e *SyntaxError) Error() string</pre> <h2 id="TagExpr">type <span>TagExpr</span> <span title="Added in Go 1.16">1.16</span> </h2> <p>A TagExpr is an <a href="#Expr">Expr</a> for the single tag Tag. </p>
+<pre data-language="go">type TagExpr struct {
+ Tag string // for example, “linux” or “cgo”
+}
+</pre> <h3 id="TagExpr.Eval">func (*TagExpr) <span>Eval</span> <span title="Added in Go 1.16">1.16</span> </h3> <pre data-language="go">func (x *TagExpr) Eval(ok func(tag string) bool) bool</pre> <h3 id="TagExpr.String">func (*TagExpr) <span>String</span> <span title="Added in Go 1.16">1.16</span> </h3> <pre data-language="go">func (x *TagExpr) String() string</pre><div class="_attribution">
+ <p class="_attribution-p">
+ &copy; Google, Inc.<br>Licensed under the Creative Commons Attribution License 3.0.<br>
+ <a href="http://golang.org/pkg/go/build/constraint/" class="_attribution-link">http://golang.org/pkg/go/build/constraint/</a>
+ </p>
+</div>