Documentation ¶
Overview ¶
A tool to generate stub implementation of an interface.
Index ¶
- func Generate(opts *GenOpts, out io.Writer) error
- type Arg
- type GenOpts
- func (opts *GenOpts) Clean(s string) string
- func (GenOpts) First(s string) string
- func (opts *GenOpts) GetName(t reflect.Type) string
- func (opts *GenOpts) Method(recName string, ft reflect.Method) Method
- func (opts *GenOpts) Methods(it reflect.Type) []Method
- func (opts *GenOpts) Short(t reflect.Type, cur map[string]struct{}) string
- type Method
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Arg ¶
type Arg struct { reflect.Type ArgName string // Name for a variable for this arg. Sep string // Separator - empty if it the last arg in a list, comma otherwise. }
Arg describes an argument of a method: either in or out.
type GenOpts ¶
type GenOpts struct { PkgName string // target package. ImplName string // type (struct) that would implement the interface. Inter reflect.Type // Interface to implement. Existing interface{} // Existing type that we want to implement the interface. NoNamedReturnValues bool // Do not generate named return values. The generated code might not compile if this is set. MethodBlacklist map[string]struct{} // Would not generate the code for those methods. Comments map[string]string // Add comments to those methods in generated code. NoGoImports bool // No goimports if set. Faster. The generated code might not compile. Extra []string // Extra imports. }
GenOpts specifies code generation options.
func (*GenOpts) Method ¶
Method populates the Method struct. recName is a name of the receiver in the generated code.
Click to show internal directories.
Click to hide internal directories.