loader

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2020 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const MaxFileSize = 50 * 1024 * 1024 // 50 MB

Variables

This section is empty.

Functions

func Load

func Load(spec *PackageSpec) (*Package, Stats, error)

Load loads the package described in spec. Imports will be loaded from export data, while the package itself will be loaded from source.

An error will only be returned for system failures, such as failure to read export data from disk. Syntax and type errors, among others, will only populate the returned package's Errors field.

func ReadELFNote

func ReadELFNote(filename, name string, typ int32) ([]byte, error)

func ReadFile

func ReadFile(name string) (id string, err error)

ReadFile reads the build ID from an archive or executable file.

Types

type Package

type Package struct {
	*PackageSpec

	// Errors that occured while loading the package. These will
	// primarily be parse or type errors, but may also be lower-level
	// failures such as file-system ones.
	Errors    []packages.Error
	Types     *types.Package
	Fset      *token.FileSet
	Syntax    []*ast.File
	TypesInfo *types.Info
}

type PackageSpec

type PackageSpec struct {
	ID      string
	Name    string
	PkgPath string
	// Errors that occured while building the import graph. These will
	// primarily be parse errors or failure to resolve imports, but
	// may also be other errors.
	Errors          []packages.Error
	GoFiles         []string
	CompiledGoFiles []string
	OtherFiles      []string
	ExportFile      string
	Imports         map[string]*PackageSpec
	TypesSizes      types.Sizes
	Hash            cache.ActionID

	Config config.Config
}

func Graph

func Graph(cfg *packages.Config, patterns ...string) ([]*PackageSpec, error)

Graph resolves patterns and returns packages with all the information required to later load type information, and optionally syntax trees.

The provided config can set any setting with the exception of Mode.

func (*PackageSpec) String

func (spec *PackageSpec) String() string

type Stats

type Stats struct {
	Source time.Duration
	Export map[*PackageSpec]time.Duration
}

Jump to

Keyboard shortcuts

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