func IsStdlibPackage(pkgPath string) bool
An AmbiguousImportError indicates an import of a package found in multiple modules in the build list, or found in both the main module and its vendor directory.
type AmbiguousImportError struct { ImportPath string Locations [][]module.SourceLoc Modules []module.Version // Either empty or 1:1 with Dirs. }
func (e *AmbiguousImportError) Error() string
Flags is a set of flags tracking metadata about a package.
type Flags int8
const ( // PkgInAll indicates that the package is in the "all" package pattern, // regardless of whether we are loading the "all" package pattern. // // When the PkgInAll flag and PkgImportsLoaded flags are both set, the caller // who set the last of those flags must propagate the PkgInAll marking to all // of the imports of the marked package. PkgInAll Flags = 1 << iota // PkgIsRoot indicates that the package matches one of the root package // patterns requested by the caller. PkgIsRoot // PkgFromRoot indicates that the package is in the transitive closure of // imports starting at the roots. (Note that every package marked as PkgIsRoot // is also trivially marked PkgFromRoot.) PkgFromRoot // PkgImportsLoaded indicates that the Imports field of a // Pkg have been populated. PkgImportsLoaded )
func (f Flags) String() string
ImportMissingError is used for errors where an imported package cannot be found.
type ImportMissingError struct { Path string }
func (e *ImportMissingError) Error() string
type Package struct {
// contains filtered or unexported fields
}
func (pkg *Package) Error() error
func (pkg *Package) Flags() Flags
func (pkg *Package) FromExternalModule() bool
func (pkg *Package) HasFlags(flags Flags) bool
func (pkg *Package) ImportPath() string
func (pkg *Package) Imports() []*Package
func (pkg *Package) Locations() []module.SourceLoc
func (pkg *Package) Mod() module.Version
func (pkg *Package) SetError(err error)
type Packages struct {
// contains filtered or unexported fields
}
func LoadPackages( ctx context.Context, mainModulePath string, mainModuleLoc module.SourceLoc, rs *modrequirements.Requirements, reg Registry, rootPkgPaths []string, ) *Packages
LoadPackages loads information about all the given packages and the packages they import, recursively, using modules from the given requirements to determine which modules they might be obtained from, and reg to download module contents.
func (pkgs *Packages) All() []*Package
func (pkgs *Packages) Pkg(pkgPath string) *Package
func (pkgs *Packages) Roots() []*Package
Registry represents a module registry, or at least this package's view of it.
type Registry interface { // Fetch returns the location of the contents for the given module // version, downloading it if necessary. Fetch(ctx context.Context, m module.Version) (module.SourceLoc, error) }