Documentation
¶
Index ¶
- type Generator
- type Method
- func (m Method) Call() string
- func (m Method) Declaration() string
- func (m Method) HasParams() bool
- func (m Method) HasResults() bool
- func (m Method) Pass(prefix string) string
- func (m Method) ResultsNames() string
- func (m Method) ResultsStruct() string
- func (m Method) ReturnStruct(structName string) string
- func (m Method) Signature() string
- type Options
- type Param
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Generator ¶
type Generator struct {
Options
// contains filtered or unexported fields
}
Generator generates decorators for the interface types
func NewGenerator ¶
NewGenerator returns Generator initialized with options
type Method ¶
type Method struct {
Name string
Params []Param
Results []Param
ReturnsError bool
AcceptsContext bool
}
Method represents a method's signature
func (Method) Declaration ¶
Declaration returns a method name followed by it's signature
func (Method) HasResults ¶
HasResults returns true if method has results
func (Method) Pass ¶
Pass returns a return statement followed by the method call If method does not have any results it returns a method call followed by return statement
func (Method) ResultsNames ¶
ResultsNames returns a list of method results names
func (Method) ResultsStruct ¶
ResultsStruct returns a struct type with fields corresponding to the method params
func (Method) ReturnStruct ¶
ReturnStruct returns return statement with the return params taken from the structName
type Options ¶
type Options struct {
//InterfaceName is a name of interface type
InterfaceName string
//SourcePackageDir is a real path of the package that contains source interface
SourcePackageDir string
//OutputFile name which is used to detect destination package name and also to fix imports in the resulting source
OutputFile string
//HeaderTemplate is used to generate package clause and comment over the generated source
HeaderTemplate string
//BodyTemplate generates import section, decorator constructor and methods
BodyTemplate string
//Vars additional vars that are passed to the templates
Vars map[string]interface{}
//Funcs is a map of helper functions that can be used within a template
Funcs template.FuncMap
}
Options of the NewGenerator constructor