Documentation ¶
Index ¶
- func CleanPatterns(patterns []string) []string
- func InDir(path, dir string) string
- func IsMetaPackage(name string) bool
- func IsRelativePath(pattern string) bool
- func IsStandardImportPath(path string) bool
- func MatchPattern(pattern string) func(name string) bool
- func SetModRoot(dir string)
- func TreeCanMatchPattern(pattern string) func(name string) bool
- func WarnUnmatched(matches []*Match)
- type Match
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanPatterns ¶
CleanPatterns returns the patterns to use for the given command line. It canonicalizes the patterns but does not evaluate any matches. For patterns that are not local or absolute paths, it preserves text after '@' to avoid modifying version queries.
func InDir ¶
InDir checks whether path is in the file tree rooted at dir. If so, InDir returns an equivalent path relative to dir. If not, InDir returns an empty string. InDir makes some effort to succeed even in the presence of symbolic links. TODO(rsc): Replace internal/test.inDir with a call to this function for Go 1.12.
func IsMetaPackage ¶
IsMetaPackage checks if name is a reserved package name that expands to multiple packages.
func IsRelativePath ¶
IsRelativePath reports whether pattern should be interpreted as a directory path relative to the current directory, as opposed to a pattern matching import paths.
func IsStandardImportPath ¶
IsStandardImportPath reports whether $GOROOT/src/path should be considered part of the standard distribution. For historical reasons we allow people to add their own code to $GOROOT instead of using $GOPATH, but we assume that code will start with a domain name (dot in the first element).
Note that this function is meant to evaluate whether a directory found in GOROOT should be treated as part of the standard library. It should not be used to decide that a directory found in GOPATH should be rejected: directories in GOPATH need not have dots in the first element, and they just take their chances with future collisions in the standard library.
func MatchPattern ¶
MatchPattern(pattern)(name) reports whether name matches pattern. Pattern is a limited glob pattern in which '...' means 'any string' and there is no other special syntax. Unfortunately, there are two special cases. Quoting "go help packages":
First, /... at the end of the pattern can match an empty string, so that net/... matches both net and packages in its subdirectories, like net/http. Second, any slash-separated pattern element containing a wildcard never participates in a match of the "vendor" element in the path of a vendored package, so that ./... does not match packages in subdirectories of ./vendor or ./mycode/vendor, but ./vendor/... and ./mycode/vendor/... do. Note, however, that a directory named vendor that itself contains code is not a vendored package: cmd/vendor would be a command named vendor, and the pattern cmd/... matches it.
func SetModRoot ¶
func SetModRoot(dir string)
func TreeCanMatchPattern ¶
TreeCanMatchPattern(pattern)(name) reports whether name or children of name can possibly match pattern. Pattern is the same limited glob accepted by matchPattern.
func WarnUnmatched ¶
func WarnUnmatched(matches []*Match)
WarnUnmatched warns about patterns that didn't match any packages.
Types ¶
type Match ¶
type Match struct { Pattern string // the pattern itself Literal bool // whether it is a literal (no wildcards) Pkgs []string // matching packages (dirs or import paths) }
A Match represents the result of matching a single package pattern.
func ImportPaths ¶
ImportPaths returns the matching paths to use for the given command line. It calls ImportPathsQuiet and then WarnUnmatched.
func ImportPathsQuiet ¶
ImportPathsQuiet is like ImportPaths but does not warn about patterns with no matches.
func MatchPackages ¶
MatchPackages returns all the packages that can be found under the $GOPATH directories and $GOROOT matching pattern. The pattern is either "all" (all packages), "std" (standard packages), "cmd" (standard commands), or a path including "...".
func MatchPackagesInFS ¶
MatchPackagesInFS is like MatchPackages but is passed a pattern that begins with an absolute path or "./" or "../". On Windows, the pattern may use slash or backslash separators or a mix of both.
MatchPackagesInFS scans the tree rooted at the directory that contains the first "..." wildcard and returns a match with packages that