Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetCachedGoroot ¶ added in v0.14.0
func GetCachedGoroot(config *compileopts.Config) (string, error)
GetCachedGoroot creates a new GOROOT by merging both the standard GOROOT and the GOROOT from TinyGo using lots of symbolic links.
Types ¶
type Error ¶ added in v0.15.0
Error is a regular error but with an added import stack. This is especially useful for debugging import cycle errors.
type Errors ¶
Errors contains a list of parser errors or a list of typechecker errors for the given package.
type NoTestFilesError ¶ added in v0.18.0
type NoTestFilesError struct {
ImportPath string
}
Error returned when loading a *Program for a test binary but no test files are present.
func (NoTestFilesError) Error ¶ added in v0.18.0
func (e NoTestFilesError) Error() string
type Package ¶
type Package struct {
PackageJSON
Files []*ast.File
FileHashes map[string][]byte
CFlags []string // CFlags used during CGo preprocessing (only set if CGo is used)
CGoHeaders []string // text above 'import "C"' lines
Pkg *types.Package
// contains filtered or unexported fields
}
Package holds a loaded package, its imports, and its parsed files.
func (*Package) Check ¶
Check runs the package through the typechecker. The package must already be loaded and all dependencies must have been checked already.
Idempotent.
func (*Package) Import ¶
Import implements types.Importer. It loads and parses packages it encounters along the way, if needed.
func (*Package) LoadSSA ¶ added in v0.17.0
LoadSSA constructs the SSA form of this package.
The program must already be parsed and type-checked with the .Parse() method.
func (*Package) OriginalDir ¶ added in v0.21.0
OriginalDir returns the real directory name. It is the same as p.Dir except that if it is part of the cached GOROOT, its real location is returned.
type PackageJSON ¶ added in v0.15.0
type PackageJSON struct {
Dir string
ImportPath string
Name string
ForTest string
Root string
Module struct {
Path string
Main bool
Dir string
GoMod string
GoVersion string
}
// Source files
GoFiles []string
CgoFiles []string
CFiles []string
// Dependency information
Imports []string
ImportMap map[string]string
// Error information
Error *struct {
ImportStack []string
Pos string
Err string
}
}
PackageJSON is a subset of the JSON struct returned from `go list`.
type Program ¶
type Program struct {
Packages map[string]*Package
// Information obtained during parsing.
LDFlags []string
// contains filtered or unexported fields
}
Program holds all packages and some metadata about the program as a whole.
func Load ¶ added in v0.15.0
func Load(config *compileopts.Config, inputPkgs []string, clangHeaders string, typeChecker types.Config) (*Program, error)
Load loads the given package with all dependencies (including the runtime package). Call .Parse() afterwards to parse all Go files (including CGo processing, if necessary).
func (*Program) LoadSSA ¶
LoadSSA constructs the SSA form of the loaded packages.
The program must already be parsed and type-checked with the .Parse() method.
func (*Program) MainPkg ¶ added in v0.14.0
MainPkg returns the last package in the Sorted() slice. This is the main package of the program.