Documentation
¶
Overview ¶
Package load wraps go/packages so that the rest of Loom works with a single, consistent go/types universe.
A single packages.Load call is essential: types from two different loads are never types.Identical, so graph resolution would silently fail across package boundaries. Build constraints are handled by the go toolchain; Loom never parses //go:build lines itself.
Index ¶
Constants ¶
const GeneratedFile = "loom_gen.go"
GeneratedFile is the base name of the file Loom writes. Loom owns this file outright: it is always rewritten in full, so diagnostics inside it never describe a real problem in the input.
const Mode = packages.NeedName | packages.NeedFiles | packages.NeedCompiledGoFiles | packages.NeedImports | packages.NeedDeps | packages.NeedTypes | packages.NeedSyntax | packages.NeedTypesInfo
Mode requests everything Loom needs: syntax, imports, types, and type info for the roots and every transitive dependency.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Generated ¶
type Generated struct {
// contains filtered or unexported fields
}
Generated records the functions Loom is about to emit.
Loom has no stub file: the initializer only comes into existence when the generated file is written. On a first run every call site of that initializer is therefore reported by the type checker as "undefined", which must not stop generation. Generated is used by Loader.CheckErrors to tell those expected errors apart from real ones.
type Loader ¶
type Loader struct {
Fset *token.FileSet
Roots []*packages.Package
// contains filtered or unexported fields
}
Loader holds the loaded package graph.
func (*Loader) CheckErrors ¶
CheckErrors returns an error if any root package reported a type error other than a reference to a function Loom is about to generate. Generated may be nil, in which case every type error is reported.