Documentation
¶
Overview ¶
Package pkgload is a set of utilities for `go/packages` load-related operations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Deduplicate ¶
Deduplicate returns a copy of pkgs slice where all duplicated package entries are removed.
Packages are considered equal if all conditions below are satisfied:
- Same ID
- Same Name
- Same PkgPath
- Equal GoFiles
func LoadPackages ¶ added in v1.2.0
LoadPackages with a given config and patterns.
func VisitUnits ¶
VisitUnits traverses potentially unsorted pkgs list as a set of units. All related packages from the slice are passed into visit func as a single unit. Units are visited in a sorted order (import path).
All packages in a slice must be non-nil.
Types ¶
type Unit ¶
type Unit struct {
// Base is a standard (normal) package.
//
// Note: it can be nil for packages that only have external
// tests, for example.
Base *packages.Package
// Test is a package compiled for test.
// Can be nil.
Test *packages.Package
// ExternalTest is a "_test" compiled package.
// Can be nil.
ExternalTest *packages.Package
// TestBinary is a test binary.
// Non-nil if Test or ExternalTest are present.
TestBinary *packages.Package
}
Unit is a set of packages that form a logical group. It is guaranteed that at least 1 field of this object is non-nil.
func (*Unit) NonNil ¶ added in v1.0.1
NonNil returns first non-nil field (package) of the unit.
- If Base is not nil, return Base.
- If Test is not nil, return Test.
- If ExternalTest is not nil, return ExternalTest.
- Otherwise return TestBinary.
If all unit fields are nil, method panics. This should never happen for properly-loaded units.