Documentation
¶
Overview ¶
Package parser provides code to parse go files, type-check them, extract the types.
Index ¶
- type Options
- type Parser
- func (p *Parser) FindPackages(patterns ...string) ([]string, error)
- func (p *Parser) LoadPackages(patterns ...string) error
- func (p *Parser) LoadPackagesTo(u *types.Universe, patterns ...string) ([]*types.Package, error)
- func (p *Parser) LoadPackagesWithConfigForTesting(cfg *packages.Config, patterns ...string) error
- func (p *Parser) NewUniverse() (types.Universe, error)
- func (p *Parser) UserRequestedPackages() []string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct { // BuildTags is a list of optional tags to be specified when loading // packages. BuildTags []string }
Options holds optional settings for the Parser.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser lets you add all the go files in all the packages that you care about, then constructs the type source data.
func NewWithOptions ¶
func (*Parser) FindPackages ¶
FindPackages expands the provided patterns into a list of Go import-paths, much like `go list -find`.
func (*Parser) LoadPackages ¶
LoadPackages loads and parses the specified Go packages. Specifically named packages (without a trailing "/...") which do not exist or have no Go files are an error.
func (*Parser) LoadPackagesTo ¶
LoadPackagesTo loads and parses the specified Go packages, and inserts them into the specified Universe. It returns the packages which match the patterns, but loads all packages and their imports, recursively, into the universe. See NewUniverse for more.
func (*Parser) LoadPackagesWithConfigForTesting ¶
LoadPackagesWithConfigForTesting loads and parses the specified Go packages with the specified packages.Config as a starting point. This is for testing, and only the .Dir and .Env fields of the Config will be considered.
func (*Parser) NewUniverse ¶
NewUniverse finalizes the loaded packages, searches through them for types and produces a new Universe. The returned Universe has one types.Package entry for each Go package that has been loaded, including all of their dependencies, recursively. It also has one entry, whose key is "", which represents "builtin" types.
func (*Parser) UserRequestedPackages ¶
UserRequestedPackages fetches a list of the user-imported packages.