toolshonnef.co/go/tools/go/loader Index | Files

package loader

import "honnef.co/go/tools/go/loader"

Index

Constants

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

Functions

func Load

func Load(spec *PackageSpec, opts *Options) (*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 Options

type Options struct {
	// The Go language version to use for the type checker. If unset, or if set
	// to "module", it will default to the Go version specified in the module;
	// if there is no module, it will default to the version of Go the
	// executable was built with.
	GoVersion string
}

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
}

Source Files

hash.go loader.go

Version
v0.5.0
Published
Aug 13, 2024
Platform
windows/amd64
Imports
19 packages
Last checked
14 seconds ago

Tools for package owners.