packages

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NeedName  = packages.NeedName
	NeedFiles = packages.NeedFiles

	NeedSyntax     = packages.NeedSyntax
	NeedImports    = packages.NeedImports
	NeedDeps       = packages.NeedDeps
	NeedModule     = packages.NeedModule
	NeedExportFile = packages.NeedExportFile

	NeedEmbedFiles      = packages.NeedEmbedFiles
	NeedEmbedPatterns   = packages.NeedEmbedPatterns
	NeedCompiledGoFiles = packages.NeedCompiledGoFiles

	NeedTypes      = packages.NeedTypes
	NeedTypesSizes = packages.NeedTypesSizes
	NeedTypesInfo  = packages.NeedTypesInfo
)
View Source
const (
	DebugPackagesLoad = false
)

Variables

This section is empty.

Functions

func Visit

func Visit(pkgs []*Package, pre func(*Package) bool, post func(*Package))

Visit visits all the packages in the import graph whose roots are pkgs, calling the optional pre function the first time each package is encountered (preorder), and the optional post function after a package's dependencies have been visited (postorder). The boolean result of pre(pkg) determines whether the imports of package pkg are visited.

Types

type Cached added in v0.8.9

type Cached struct {
	Types     *types.Package
	TypesInfo *types.Info
	Syntax    []*ast.File
}

type Config

type Config = packages.Config

A Config specifies details about how packages should be loaded. The zero value is a valid configuration. Calls to Load do not modify this struct.

type Deduper added in v0.8.8

type Deduper = *aDeduper

func NewDeduper added in v0.8.8

func NewDeduper() Deduper

func (Deduper) Check added in v0.8.9

func (p Deduper) Check(pkgPath string) *Cached

func (Deduper) SetPkgPath added in v0.9.2

func (p Deduper) SetPkgPath(fn func(path, name string) string)

func (Deduper) SetPreload added in v0.9.2

func (p Deduper) SetPreload(fn func(pkg *types.Package, syntax []*ast.File))

type LoadMode

type LoadMode = packages.LoadMode

A LoadMode controls the amount of detail to return when loading. The bits below can be combined to specify which fields should be filled in the result packages. The zero value is a special case, equivalent to combining the NeedName, NeedFiles, and NeedCompiledGoFiles bits. ID and Errors (if present) will always be filled. Load may return more information than requested.

type Package

type Package = packages.Package

A Package describes a loaded Go package.

func LoadEx

func LoadEx(dedup Deduper, sizes func(types.Sizes) types.Sizes, cfg *Config, patterns ...string) ([]*Package, error)

LoadEx loads and returns the Go packages named by the given patterns.

Config specifies loading options; nil behaves the same as an empty Config.

If any of the patterns was invalid as defined by the underlying build system, Load returns an error. It may return an empty list of packages without an error, for instance for an empty expansion of a valid wildcard. Errors associated with a particular package are recorded in the corresponding Package's Errors list, and do not cause Load to return an error. Clients may need to handle such errors before proceeding with further analysis. The PrintErrors function is provided for convenient display of all errors.

Jump to

Keyboard shortcuts

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