Version: v0.5.0 Latest Latest

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

Go to latest
Published: Apr 20, 2019 License: BSD-3-Clause Imports: 17 Imported by: 0




This section is empty.


This section is empty.


This section is empty.


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 ImportCycleError

type ImportCycleError struct {
	Packages        []string
	ImportPositions []token.Position

ImportCycleErrors is returned when encountering an import cycle. The list of packages is a list from the root package to the leaf package that imports one of the packages in the list.

func (*ImportCycleError) Error

func (e *ImportCycleError) Error() string

type Package

type Package struct {
	Imports   map[string]*Package
	Importing bool
	Files     []*ast.File
	Pkg       *types.Package

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) Parse

func (p *Package) Parse() error

Parse parses and typechecks this package.


type Program

type Program struct {
	Build         *build.Context
	OverlayBuild  *build.Context
	ShouldOverlay func(path string) bool
	Packages      map[string]*Package

	TypeChecker types.Config
	Dir         string // current working directory (for error reporting)
	CFlags      []string
	// contains filtered or unexported fields

Program holds all packages and some metadata about the program as a whole.

func (*Program) Import

func (p *Program) Import(path, srcDir string) (*Package, error)

Import loads the given package relative to srcDir (for the vendor directory). It only loads the current package without recursion.

func (*Program) ImportFile

func (p *Program) ImportFile(path string) (*Package, error)

ImportFile loads and parses the import statements in the given path and creates a pseudo-package out of it.

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) Parse

func (p *Program) Parse() error

Parse recursively imports all packages, parses them, 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.

type RefMap

type RefMap struct {
	// contains filtered or unexported fields

RefMap is a convenient way to store opaque references that can be passed to C. It is useful if an API uses function pointers and you cannot pass a Go pointer but only a C pointer.

func (*RefMap) Get

func (m *RefMap) Get(ref unsafe.Pointer) interface{}

Get returns a stored value previously inserted with Put. Use the same reference as you got from Put.

func (*RefMap) Put

func (m *RefMap) Put(v interface{}) unsafe.Pointer

Put stores a value in the map. It can later be retrieved using Get. It must be removed using Remove to avoid memory leaks.

func (*RefMap) Remove

func (m *RefMap) Remove(ref unsafe.Pointer)

Remove deletes a single reference from the map.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto