Documentation
¶
Index ¶
- func RemoveGenFiles(workDir string) error
- func WriteGenFiles(res *Result, workDir string, verbose bool) error
- type Args
- type Backends
- type BackendsDep
- type Node
- type NodeSelection
- type NodeType
- type PkgCache
- type Result
- type SelectResult
- type Selector
- type TplData
- type TplDep
- type TplImport
- type TplParam
- type TplProvider
- type TypeMap
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RemoveGenFiles ¶
RemoveGenFiles removes previously generated files. During Generate these files can cause issues if they contain syntax or other compilation errors.
Types ¶
type Backends ¶
type Backends struct {
// Name of the backends interface, usually Backends.
Name string
// Type is the actual Backends interface type itself.
Type types.Type
// Package of the backends.
Package *types.Package
// Deps is the list of dependencies provided by the backends.
Deps []BackendsDep
}
Backends represents a Backends interface.
type BackendsDep ¶
type Node ¶
type Node struct {
// Type of the node.
Type NodeType
// Parent of this node in the provider set graph (nil if root).
Parent *Node
// Children of this node in the provider set graph.
Children []*Node
// Deps is descendents' provided types.
Deps []types.Type
// HasDups indicates if this node has duplicate providers.
HasDups bool
// VarPkg is the fully qualified package if the provider set is assigned to a variable.
VarPkg string
// VarName is the variable name if the provider set is assigned to a variable.
VarName string
FuncObj types.Object
FuncSig *types.Signature
FuncResult types.Type
BindInterface types.Type
BindImpl types.Type
}
Node represents provider in a provider set graph.
type NodeSelection ¶
type NodeSelection struct {
// SelectedNodes is all the functions that need to be called in order
// to create the weld state
SelectedNodes []Node
// TransitiveBackends is the other backends that needed to be satisfied by required nodes
TransitiveBackends []Backends
// UnselectedTypes is a list of parameters that could not be satisfied by dependencies
UnselectedTypes []types.Type
}
type PkgCache ¶
type PkgCache struct {
// In is the package path that has the weld spec.
In string
// Out is the package that generated files are being written to.
Out string
// Pkgs is a map of imported packages by path
Pkgs map[string]TplImport
// Names is map of packages paths by import alias/name.
Names map[string]string
}
PkgCache manages the packages used in code generation providing imports including aliases and type references.
func NewPkgCache ¶
type Result ¶
type SelectResult ¶
type Selector ¶
type Selector struct {
// contains filtered or unexported fields
}
func NewSelector ¶
func (*Selector) AddBackends ¶
func (*Selector) GetBackends ¶
type TplData ¶
type TplData struct {
// Package is the generated source package name.
Package string
// Tags is the build tags string
Tags string
BackendsType string // Backends or ops.Backends
BackendsName string // Backends
// Imports are the imported packages by package path.
Imports map[string]TplImport
Params []TplParam
Deps []TplDep
TransBcks []string // _ email_logical.Backends = (*backendsImpl)(nil)
}
func (TplData) DepsReturnErr ¶
DepsReturnErr returns true if any dependency returns an error. This determines whether or not `err` should be declared.
func (TplData) ParamsString ¶
type TplDep ¶
type TplDep struct {
Type string // *email_db.EmailDB
Var string // emailDB
Getter string // EmailDB
IsDuplicate bool
Provider TplProvider
}
type TplProvider ¶
type TplProvider struct {
FuncPkg string // email_db
FuncName string // Connect
ReturnsErr bool // s.email, err = email_db.Connect()
Params []string
ErrWrapMsg string // return nil, errors.Wrap(err, "email db connect")
}
func (TplProvider) FormatArgs ¶
func (p TplProvider) FormatArgs() string
func (TplProvider) FormatFunc ¶
func (p TplProvider) FormatFunc() string
Click to show internal directories.
Click to hide internal directories.