search

package
v0.9.2202 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 21, 2024 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanPatterns

func CleanPatterns(patterns []string) []string

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

func InDir(path, dir string) string

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.

func IsMetaPackage

func IsMetaPackage(name string) bool

IsMetaPackage checks if name is a reserved package name that expands to multiple packages.

func IsRelativePath

func IsRelativePath(pattern string) bool

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

func IsStandardImportPath(path string) bool

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 WarnUnmatched

func WarnUnmatched(matches []*Match)

WarnUnmatched warns about patterns that didn't match any packages.

Types

type Match

type Match struct {
	Dirs []string // if the pattern is local, directories that potentially contain matching packages
	Pkgs []string // matching packages (import paths)
	Errs []error  // errors matching the patterns to packages, NOT errors loading those packages
	// contains filtered or unexported fields
}

A Match represents the result of matching a single package pattern.

func ImportPaths

func ImportPaths(patterns, modRoots []string) []*Match

ImportPaths returns the matching paths to use for the given command line. It calls ImportPathsQuiet and then WarnUnmatched.

func ImportPathsQuiet

func ImportPathsQuiet(patterns, modRoots []string) []*Match

ImportPathsQuiet is like ImportPaths but does not warn about patterns with no matches.

func NewMatch

func NewMatch(pattern string) *Match

NewMatch returns a Match describing the given pattern, without resolving its packages or errors.

func (*Match) AddError

func (m *Match) AddError(err error)

AddError appends a MatchError wrapping err to m.Errs.

func (*Match) IsLiteral

func (m *Match) IsLiteral() bool

IsLiteral reports whether the pattern is free of wildcards and meta-patterns.

A literal pattern must match at most one package.

func (*Match) IsLocal

func (m *Match) IsLocal() bool

IsLocal reports whether the pattern must be resolved from a specific root or directory, such as a filesystem path or a single module.

func (*Match) IsMeta

func (m *Match) IsMeta() bool

IsMeta reports whether the pattern is a “meta-package” keyword that represents multiple packages, such as "std", "cmd", or "all".

func (*Match) MatchDirs

func (m *Match) MatchDirs(modRoots []string)

MatchDirs sets m.Dirs to a non-nil slice containing all directories that potentially match a local pattern. The pattern must begin with an absolute path, or "./", or "../". On Windows, the pattern may use slash or backslash separators or a mix of both.

If any errors may have caused the set of directories to be incomplete, MatchDirs appends those errors to m.Errs.

func (*Match) MatchPackages

func (m *Match) MatchPackages()

MatchPackages sets m.Pkgs to a non-nil slice containing all the packages that can be found under the $GOPATH directories and $GOROOT that match the pattern. The pattern must be either "all" (all packages), "std" (standard packages), "cmd" (standard commands), or a path including "...".

If any errors may have caused the set of packages to be incomplete, MatchPackages appends those errors to m.Errs.

func (*Match) Pattern

func (m *Match) Pattern() string

Pattern returns the pattern to be matched.

type MatchError

type MatchError struct {
	Match *Match
	Err   error
}

A MatchError indicates an error that occurred while attempting to match a pattern.

func (*MatchError) Error

func (e *MatchError) Error() string

func (*MatchError) Unwrap

func (e *MatchError) Unwrap() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL