Documentation ¶
Index ¶
- type Fake
- type FakeMode
- type Import
- type Imports
- type Method
- type Param
- type Params
- func (p Params) AsArgs() string
- func (p Params) AsNamedArgs() string
- func (p Params) AsNamedArgsForInvocation() string
- func (p Params) AsNamedArgsWithTypes() string
- func (p Params) AsReturnSignature() string
- func (p Params) HasLength() bool
- func (p Params) Slices() Params
- func (p Params) WithPrefix(prefix string) string
- type Return
- type Returns
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Fake ¶
type Fake struct { Packages []*packages.Package Package *packages.Package Target *types.TypeName Mode FakeMode DestinationPackage string Name string TargetAlias string TargetName string TargetPackage string Imports Imports Methods []Method Function Method }
Fake is used to generate a Fake implementation of an interface.
func NewFake ¶
func NewFake(fakeMode FakeMode, targetName string, packagePath string, fakeName string, destinationPackage string, workingDir string) (*Fake, error)
NewFake returns a Fake that loads the package and finds the interface or the function.
func (*Fake) Generate ¶
Generate uses the Fake to generate an implementation, optionally running goimports on the output.
func (*Fake) IsFunction ¶
IsFunction indicates whether the fake is for a function..
func (*Fake) IsInterface ¶
IsInterface indicates whether the fake is for an interface.
type Imports ¶
Imports indexes imports by package path and alias so that all imports have a unique alias, and no package is included twice.
type Params ¶
type Params []Param
Params is a slice of Param.
func (Params) AsArgs ¶
AsArgs builds a string that represents the parameters to a function as arguments to a function invocation.
func (Params) AsNamedArgs ¶
AsNamedArgs builds a string that represents parameters as named arguments.
func (Params) AsNamedArgsForInvocation ¶
AsNamedArgsForInvocation builds a string that represents a function's arguments as required for invocation of the function.
func (Params) AsNamedArgsWithTypes ¶
AsNamedArgsWithTypes builds a string that represents parameters as named arugments to a function, with associated types.
func (Params) AsReturnSignature ¶
AsReturnSignature builds a string representing signature for the params of a function.
func (Params) HasLength ¶
HasLength returns true if there are params. It returns false if there are no params.
func (Params) WithPrefix ¶
WithPrefix builds a string representing a functions parameters, and adds a prefix to each.
type Returns ¶
type Returns []Return
Returns is a slice of Return.
func (Returns) AsNamedArgs ¶
AsNamedArgs builds a string representing a function's named arguments.
func (Returns) AsNamedArgsWithTypes ¶
AsNamedArgsWithTypes builds a string representing a function's named arguments, with associated types.
func (Returns) AsReturnSignature ¶
AsReturnSignature builds a string representing signature for the returns of a function.
func (Returns) WithPrefix ¶
WithPrefix builds a string representing the parameters returned from a function, and adds a prefix to each.