loader

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Overview

Package loader parses and type-checks Go packages using only the standard library. It deliberately avoids golang.org/x/tools/go/packages so gox has zero external dependencies.

The loader shells out to `go list -json` to discover the import graph and then drives go/parser + go/types directly. List is split from LoadPackage so callers can cheaply enumerate packages (and their file metadata) without paying for parse + type-check on cache hits.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Package

type Package struct {
	Info       *PackageInfo
	Fset       *token.FileSet
	Files      []*ast.File
	Pkg        *types.Package
	TypesInfo  *types.Info
	TypeErrors []error
}

Package is a fully-parsed and type-checked Go package.

func Load

func Load(patterns ...string) ([]*Package, error)

Load is a convenience wrapper that lists and fully loads every package matched by patterns. Use List + LoadPackage when you want per-package control (e.g. to consult a cache before parsing).

func LoadPackage

func LoadPackage(info *PackageInfo) (*Package, error)

LoadPackage parses and type-checks a single package.

type PackageInfo

type PackageInfo struct {
	ImportPath string
	Dir        string
	GoFiles    []string // basenames as reported by `go list`
}

PackageInfo is the lightweight package metadata produced by List.

func List

func List(patterns ...string) ([]*PackageInfo, error)

List enumerates the packages matched by the patterns and returns their file metadata without parsing them.

func (*PackageInfo) AbsFiles

func (p *PackageInfo) AbsFiles() []string

AbsFiles returns the absolute paths of the package's .go files.

Jump to

Keyboard shortcuts

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