Documentation
¶
Overview ¶
Package constraintはビルド制約行の解析と評価を実装しています。 ビルド制約自体のドキュメントについては、https://golang.org/cmd/go/#hdr-Build_constraintsを参照してください。
このパッケージは、オリジナルの「// +build」構文と、Go 1.17で追加された「//go:build」構文の両方を解析します。 「//go:build」構文の詳細については、https://golang.org/design/draft-gobuildを参照してください。
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GoVersion ¶ added in v1.21.0
GoVersionは与えられたビルド条件によって暗黙的に指定される最小のGoバージョンを返します。 条件式にGoバージョンタグがない場合、GoVersionは空の文字列を返します。
例:
GoVersion(linux && go1.22) = "go1.22" GoVersion((linux && go1.22) || (windows && go1.20)) = "go1.20" => go1.20 GoVersion(linux) = "" GoVersion(linux || (windows && go1.22)) = "" GoVersion(!go1.22) = ""
GoVersionは、任意のタグまたは否定されたタグが独立してtrueである可能性があると仮定しています。 そのため、解析はSATソルバーなしで純粋に構造的に行われます。 「不可能」とされる部分式は結果に影響する可能性があるためです。
例:
GoVersion((linux && !linux && go1.20) || go1.21) = "go1.20"
func IsGoBuild ¶
IsGoBuildは、テキストの行が「//go:build」の制約であるかどうかを報告します。 これは、テキストのプレフィックスのみをチェックし、式自体の解析は行いません。
func IsPlusBuild ¶
IsPlusBuildはテキストの行が "// +build" 制約であるかどうかを報告します。 これはテキストの接頭辞のみをチェックし、式そのものの解析は行いません。
func PlusBuildLines ¶
PlusBuildLinesはビルド式xに評価される「// +build」の行のシーケンスを返します。 式が直接「// +build」の行に変換できるほど複雑でない場合、PlusBuildLinesはエラーを返します。
Types ¶
type Expr ¶
type Expr interface {
String() string
Eval(ok func(tag string) bool) bool
// contains filtered or unexported methods
}
Exprはビルドタグの制約式です。 内部の具体的な型は*AndExpr、*OrExpr、*NotExpr、または*TagExpr です。
type SyntaxError ¶
SyntaxErrorは解析されたビルド式の構文エラーを報告します。
func (*SyntaxError) Error ¶
func (e *SyntaxError) Error() string