Documentation
¶
Overview ¶
Package layout places generated parts in files and gives each folder its package name and import path.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrUnknownSelector = errors.New("unknown selector") ErrSelectorConflict = errors.New("selector conflict") ErrNoModule = errors.New("no module path") ErrOutsideModule = errors.New("outside the module") ErrImportCycle = errors.New("import cycle") ErrModule = errors.New("read go.mod") ErrPackageConflict = errors.New("two packages in one folder") ErrSplitParts = errors.New("parts that belong together are in different folders") )
Functions ¶
This section is empty.
Types ¶
type File ¶
type File struct {
Path string
Rel string
Package string
ImportPath string
Parts []PartID
Kind FileKind
}
File is one output file. Path is resolved against the config folder; Rel is the path as the config writes it. Parts keep the order the generators gave.
type Layout ¶
Layout holds the files that got at least one part, sorted by path. Package is the package of output.file, which is not among them when every part went elsewhere.
func Plan ¶
Plan puts every part in the file whose selector matches it most closely, output.file when none does, then names the package and import path of every folder.
func (*Layout) CheckImports ¶
CheckImports fails when the folders import each other in a cycle through what the parts wrote, which Plan cannot see for the code of an extra file. imports lists, by part, the import paths its file held once the part was written, so a path counts for the first part of a file that has it.
type Module ¶
Module is the Go module the output belongs to. Path is empty when none is known.
func FindModule ¶
FindModule reads the nearest go.mod in dir or above it. A non-empty override replaces its module path; without a go.mod, the module is override rooted at dir.
type Part ¶
Part is a part a generator writes, with the parts its code refers to. Package, when set, is the package name of the file that holds it, whatever its folder is called: main for a program. Owner, when set, is the part whose folder this one must share, and Reason says why, after the ID.