loader

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2022 License: MIT Imports: 17 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.

Types

type Package

type Package struct {
	*PackageSpec

	// Errors that occurred 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 occurred 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
	Module          *packages.Module

	Config config.Config
}

func Graph

func Graph(c *cache.Cache, 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