Documentation ¶
Overview ¶
Package printer conatains code generator using analyzer's models.
Index ¶
- Variables
- type Convertor
- func (c *Convertor) ArgumentString(a *model.Argument) string
- func (c *Convertor) ArgumentTypeConvertString(a *model.Argument) string
- func (c *Convertor) ArgumentTypeString(a *model.Argument) string
- func (c *Convertor) GetPkgPathName(pkgPath string) string
- func (c *Convertor) GetQualifiedType(pkgPath, typeName string) string
- func (c *Convertor) GetZeroValue(arg *model.Argument) string
- func (c *Convertor) MethodTuplesString(m *model.Method) string
- func (c *Convertor) PrintFileImports() string
- func (c *Convertor) SetFileParams(currentPkg string)
- type Printer
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidConfig = errors.New("invalid config")
ErrInvalidConfig returns when you create printer with invalid config params.
Functions ¶
This section is empty.
Types ¶
type Convertor ¶
type Convertor struct {
// contains filtered or unexported fields
}
Convertor converts models to code.
func NewConvertor ¶
func NewConvertor() *Convertor
NewConvertor returns a new converter based on a pkg name of the generated file.
func (*Convertor) ArgumentString ¶
ArgumentString converts method's argument in string.
func (*Convertor) ArgumentTypeConvertString ¶
ArgumentTypeConvertString converts method's argument type in string to pass it to the converting code. For example *pkg.Type -> v.(*pkg.Type) or ...*pkg.Type -> v.([]*pkg.Type).
func (*Convertor) ArgumentTypeString ¶
ArgumentTypeString converts method's argument type in string.
func (*Convertor) GetPkgPathName ¶
GetPkgPathName returns name of the path pkg for types.
func (*Convertor) GetQualifiedType ¶
GetQualifiedType returns type name with package prefix.
func (*Convertor) GetZeroValue ¶
GetZeroValue returns zero value of the argument.
func (*Convertor) MethodTuplesString ¶
MethodTuplesString returns tuples string of the method or func.
func (*Convertor) PrintFileImports ¶
PrintFileImports prints all imports collected in usedImports. Prints just rows with import and alias.
func (*Convertor) SetFileParams ¶
SetFileParams resets used imports of the file and set new package name.
type Printer ¶
type Printer struct {
// contains filtered or unexported fields
}
Printer creates new genereted files with interface implementers.
func New ¶
func New(log *zerolog.Logger, conf *config.Print, stdout io.Writer, version string) (*Printer, error)
New validate config and created new code printer.
func (*Printer) GetFileName ¶
GetFileName returns file name of based on interface name and config.
func (*Printer) GetFilePath ¶
GetFilePath returns full path to the new file based on config and interface location.