Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrParserUnknownDecl = errors.New("definition files can only contain package, import, var and func declarations")
ErrParserUnknownDecl is the Parser error for unknown declarations.
var ErrParserVarDecl = errors.New("var declaration contains an error")
ErrParserVarDecl is the Parser error for invalid var declarations.
Functions ¶
This section is empty.
Types ¶
type DICopier ¶
type DICopier struct { // Output is where the repository should be copied. Output string // Box contains the di files. Box packr.Box }
DICopier is able to copy the github.com/sarulabs/di repository. The files are in github.com/sarulabs/dingo/generation/di.
func NewDICopier ¶
NewDICopier is the DICopier constructor.
type DeclarationList ¶
type DeclarationList struct {
// contains filtered or unexported fields
}
DeclarationList is the structure used to store the name of the declarations in the source files. A declaration is the name of the variable containing one or more dingo.Def.
func NewDeclarationList ¶
func NewDeclarationList() *DeclarationList
NewDeclarationList is the DeclarationList constructor.
func (*DeclarationList) Add ¶
func (dl *DeclarationList) Add(name string) error
Add adds a new declaration in the DeclarationList.
func (*DeclarationList) Merge ¶
func (dl *DeclarationList) Merge(declList *DeclarationList) error
Merge adds the declarations of the declList to the DeclarationList.
func (*DeclarationList) String ¶
func (dl *DeclarationList) String(prefix, sep string) string
String turns the declarations into a string. It works like strings.Join on the declaration names, but it also allows to add a prefix before each element.
type DefinitionCopier ¶
DefinitionCopier copies the definition files from the source directory, to the destination directory. It changes the package name in the files.
func NewDefinitionCopier ¶
func NewDefinitionCopier(loc *Locator, subDir string) *DefinitionCopier
NewDefinitionCopier is the DefinitionCopier constructor.
func (*DefinitionCopier) Copy ¶
func (cop *DefinitionCopier) Copy() error
Copy copies each source file in the destination directory.
type Generator ¶
type Generator struct { Locator *Locator Box packr.Box Declarations *DeclarationList }
Generator creates the compiler files and runs the compiler. It generates the dependency injection container.
func NewGenerator ¶
func NewGenerator(loc *Locator, box packr.Box, decls *DeclarationList) *Generator
NewGenerator is the Generator constructor.
type Locator ¶
type Locator struct {
// contains filtered or unexported fields
}
Locator provides an easy way to get information about the source and destination directories.
func NewLocator ¶
NewLocator creates an initialized Locator.
func (*Locator) DestDir ¶
DestDir returns the absolute path to the destination directory. Init should be called first.
func (*Locator) DestPkg ¶
DestPkg returns the name of the package for the files in the destination directory. Init should be called first.
func (*Locator) Init ¶
Init initialize the Locator instance with a given source and destination directories. dest must be in the $GOPATH.
func (*Locator) SourceDir ¶
SourceDir returns the absolute path to the source directory. Init should be called first.
func (*Locator) SourceDirName ¶
SourceDirName returns the name of the source directory. Init should be called first.
func (*Locator) SourceFiles ¶
SourceFiles returns the name of the go files contained in the source directory. Init should be called first.
type Parser ¶
type Parser struct {
Locator *Locator
}
Parser can find the definition declarations in the source files.
func (*Parser) Parse ¶
func (p *Parser) Parse() (*DeclarationList, error)
Parse finds the definition declarations in the source files. It may also return an error if the package name of the source file does not match the name of its directory.