gvisorgvisor.dev/gvisor/tools/constraintutil Index | Files

package constraintutil

import "gvisor.dev/gvisor/tools/constraintutil"

Package constraintutil provides utilities for working with Go build constraints.

Index

Functions

func Combine

func Combine(es []constraint.Expr) constraint.Expr

Combine returns a constraint.Expr that evaluates to true iff all expressions in es evaluate to true. If es is empty, Combine returns nil.

Preconditions: All constraint.Exprs in es are non-nil.

func CombineFromFiles

func CombineFromFiles(paths []string) (constraint.Expr, error)

CombineFromFiles returns a build constraint expression that evaluates to true iff the build constraints from all of the given Go source or assembly files evaluate to true. If no build constraints apply to any of the given files, it returns nil.

func FromFile

func FromFile(path string) (constraint.Expr, error)

FromFile extracts the build constraint from the Go source or assembly file at the given path. If no build constraint applies to the file, it returns nil.

func FromReader

func FromReader(r io.Reader) (constraint.Expr, error)

FromReader extracts the build constraint from the Go source or assembly file whose contents are read by r.

func FromString

func FromString(str string) (constraint.Expr, error)

FromString extracts the build constraint from the Go source or assembly file containing the given data. If no build constraint applies to the file, it returns nil.

func Lines

func Lines(e constraint.Expr) string

Lines returns a string containing build constraint directives for the given constraint.Expr, including two trailing newlines, as appropriate for a Go source or assembly file. At least a go:build directive will be emitted; if the constraint is expressible using +build directives as well, then +build directives will also be emitted.

If e is nil, Lines returns the empty string.

Source Files

constraintutil.go

Version
v0.0.0-20250802011938-fc9c972fa636 (latest)
Published
Aug 2, 2025
Platform
linux/amd64
Imports
7 packages
Last checked
2 hours ago

Tools for package owners.