Version: v0.19.0 Latest Latest

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

Go to latest
Published: Jun 30, 2021 License: BSD-3-Clause Imports: 25 Imported by: 3




This section is empty.


This section is empty.


func GetCachedGoroot

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.

func List

func List(config *compileopts.Config, extraArgs, pkgs []string) (*exec.Cmd, error)

List returns a ready-to-run *exec.Cmd for running the `go list` command with the configuration used for TinyGo.


type Error

type Error struct {
	ImportStack []string
	Err         scanner.Error

Error is a regular error but with an added import stack. This is especially useful for debugging import cycle errors.

func (Error) Error

func (e Error) Error() string

type Errors

type Errors struct {
	Pkg  *Package
	Errs []error

Errors contains a list of parser errors or a list of typechecker errors for the given package.

func (Errors) Error

func (e Errors) Error() string

type NoTestFilesError

type NoTestFilesError struct {
	ImportPath string

Error returned when loading a *Program for a test binary but no test files are present.

func (NoTestFilesError) Error

func (e NoTestFilesError) Error() string

type Package

type Package struct {

	Files      []*ast.File
	FileHashes map[string][]byte
	CFlags     []string // CFlags used during CGo preprocessing (only set if CGo is used)
	Pkg        *types.Package
	// contains filtered or unexported fields

Package holds a loaded package, its imports, and its parsed files.

func (*Package) Check

func (p *Package) Check() error

Check runs the package through the typechecker. The package must already be loaded and all dependencies must have been checked already.


func (*Package) Import

func (p *Package) Import(to string) (*types.Package, error)

Import implements types.Importer. It loads and parses packages it encounters along the way, if needed.

func (*Package) LoadSSA

func (p *Package) LoadSSA() *ssa.Package

LoadSSA constructs the SSA form of this package.

The program must already be parsed and type-checked with the .Parse() method.

func (*Package) Parse

func (p *Package) Parse() error

Parse parses and typechecks this package.


type PackageJSON

type PackageJSON struct {
	Dir        string
	ImportPath string
	Name       string
	ForTest    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

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

func (p *Program) LoadSSA() *ssa.Program

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

func (p *Program) MainPkg() *Package

MainPkg returns the last package in the Sorted() slice. This is the main package of the program.

func (*Program) Parse

func (p *Program) Parse() error

Parse parses all packages and typechecks them.

The returned error may be an Errors error, which contains a list of errors.


func (*Program) Sorted

func (p *Program) Sorted() []*Package

Sorted returns a list of all packages, sorted in a way that no packages come before the packages they depend upon.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to