Documentation ¶
Index ¶
- Variables
- func AnyTags() map[string]bool
- func Eval(x constraint.Expr, tags map[string]bool, prefer bool) bool
- func MatchFile(name string, tags map[string]bool) bool
- func ReadComments(f io.Reader) ([]byte, error)
- func ReadImports(f io.Reader, reportSyntaxError bool, imports *[]string) ([]byte, error)
- func ScanDir(dir string, tags map[string]bool) ([]string, []string, error)
- func ScanFiles(files []string, tags map[string]bool) ([]string, []string, error)
- func ShouldBuild(content []byte, tags map[string]bool) bool
- func Tags() map[string]bool
Constants ¶
This section is empty.
Variables ¶
var ErrNoGo = fmt.Errorf("no Go source files")
var KnownArch = map[string]bool{ "386": true, "amd64": true, "amd64p32": true, "arm": true, "armbe": true, "arm64": true, "arm64be": true, "ppc64": true, "ppc64le": true, "mips": true, "mipsle": true, "mips64": true, "mips64le": true, "mips64p32": true, "mips64p32le": true, "loong64": true, "ppc": true, "riscv": true, "riscv64": true, "s390": true, "s390x": true, "sparc": true, "sparc64": true, "wasm": true, }
var KnownOS = map[string]bool{ "aix": true, "android": true, "darwin": true, "dragonfly": true, "freebsd": true, "hurd": true, "illumos": true, "ios": true, "js": true, "linux": true, "nacl": true, "netbsd": true, "openbsd": true, "plan9": true, "solaris": true, "wasip1": true, "windows": true, "zos": true, }
Functions ¶
func AnyTags ¶
AnyTags returns a special set of build tags that satisfy nearly all build tag expressions. Only "ignore" and malformed build tag requirements are considered false.
func Eval ¶
Eval is like
x.Eval(func(tag string) bool { return matchTag(tag, tags) })
except that it implements the special case for tags["*"] meaning all tags are both true and false at the same time.
func MatchFile ¶
MatchFile returns false if the name contains a $GOOS or $GOARCH suffix which does not match the current system. The recognized name formats are:
name_$(GOOS).* name_$(GOARCH).* name_$(GOOS)_$(GOARCH).* name_$(GOOS)_test.* name_$(GOARCH)_test.* name_$(GOOS)_$(GOARCH)_test.*
Exceptions:
if GOOS=android, then files with GOOS=linux are also matched. if GOOS=illumos, then files with GOOS=solaris are also matched. if GOOS=ios, then files with GOOS=darwin are also matched.
If tags["*"] is true, then MatchFile will consider all possible GOOS and GOARCH to be available and will consequently always return true.
func ReadComments ¶
ReadComments is like io.ReadAll, except that it only reads the leading block of comments in the file.
func ReadImports ¶
ReadImports is like io.ReadAll, except that it expects a Go file as input and stops reading the input once the imports have completed.
func ShouldBuild ¶
ShouldBuild reports whether it is okay to use this file, The rule is that in the file's leading run of // comments and blank lines, which must be followed by a blank line (to avoid including a Go package clause doc comment), lines beginning with '// +build' are taken as build directives.
The file is accepted only if each such line lists something matching the file. For example:
// +build windows linux
marks the file as applicable only on Windows and Linux.
If tags["*"] is true, then ShouldBuild will consider every build tag except "ignore" to be both true and false for the purpose of satisfying build tags, in order to estimate (conservatively) whether a file could ever possibly be used in any build.
Types ¶
This section is empty.