Documentation ¶
Index ¶
- func IsStdlibPackage(pkgPath string) bool
- type AmbiguousImportError
- type Flags
- type ImportMissingError
- type Package
- 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
- type Registry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsStdlibPackage ¶
Types ¶
type AmbiguousImportError ¶
type AmbiguousImportError struct { ImportPath string Locations [][]module.SourceLoc Modules []module.Version // Either empty or 1:1 with Dirs. }
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.
func (*AmbiguousImportError) Error ¶
func (e *AmbiguousImportError) Error() string
type Flags ¶
type Flags int8
Flags is a set of flags tracking metadata about a package.
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 )
type ImportMissingError ¶
type ImportMissingError struct {
Path string
}
ImportMissingError is used for errors where an imported package cannot be found.
func (*ImportMissingError) Error ¶
func (e *ImportMissingError) Error() string
type Package ¶
type Package struct {
// contains filtered or unexported fields
}
func (*Package) FromExternalModule ¶
func (*Package) ImportPath ¶
type Packages ¶
type Packages struct {
// contains filtered or unexported fields
}
func LoadPackages ¶
func LoadPackages( ctx context.Context, mainModulePath string, mainModuleLoc module.SourceLoc, rs *modrequirements.Requirements, reg Registry, rootPkgPaths []string, shouldIncludePkgFile func(pkgPath string, mod module.Version, fsys fs.FS, mf modimports.ModuleFile) bool, ) *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.
rootPkgPaths should only contain canonical import paths.
The shouldIncludePkgFile function is used to determine whether a given file in a package should be considered to be part of the build. If it returns true for a package, the file's imports will be followed. A nil value corresponds to a function that always returns true. It may be called concurrently.
type Registry ¶
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) }
Registry represents a module registry, or at least this package's view of it.