Documentation
¶
Index ¶
- Variables
- func IsAutoGenerated(path *pathlib.Path) (bool, error)
- type Config
- func (c *Config) CfgAsMap(ctx context.Context) (map[string]any, error)
- func (c *Config) ClearCfgAsMap()
- func (c *Config) ExcludePath(path string) bool
- func (c *Config) FilePath(ctx context.Context) *pathlib.Path
- func (c *Config) GetInterfaceConfig(ctx context.Context, packageName string, interfaceName string) ([]*Config, error)
- func (c *Config) GetPackageConfig(ctx context.Context, packageName string) (*Config, error)
- func (c *Config) GetPackages(ctx context.Context) ([]string, error)
- func (c *Config) Initialize(ctx context.Context) error
- func (c *Config) ParseTemplates(ctx context.Context, iface *Interface, srcPkg *packages.Package) error
- func (c *Config) ShouldGenerateInterface(ctx context.Context, packageName, interfaceName string) (bool, error)
- func (c *Config) TagName(name string) string
- type Formatter
- type Interface
- type NodeVisitor
- type Parser
- type TemplateGenerator
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoConfigFile = fmt.Errorf("no config file exists") ErrNoGoFilesFoundInRoot = fmt.Errorf("no go files found in root search path") ErrPkgNotFound = fmt.Errorf("package not found in config") ErrGoModNotFound = fmt.Errorf("no go.mod file found") ErrGoModInvalid = fmt.Errorf("go.mod file has no module line") )
var ErrInfiniteLoop = fmt.Errorf("infinite loop in template variables detected")
Functions ¶
Types ¶
type Config ¶
type Config struct { All bool `mapstructure:"all"` Anchors map[string]any `mapstructure:"_anchors"` BoilerplateFile string `mapstructure:"boilerplate-file"` BuildTags string `mapstructure:"tags"` Config string `mapstructure:"config"` Dir string `mapstructure:"dir"` Exclude []string `mapstructure:"exclude"` ExcludeRegex string `mapstructure:"exclude-regex"` FileName string `mapstructure:"filename"` Formatter string `mapstructure:"formatter"` IncludeRegex string `mapstructure:"include-regex"` LogLevel string `mapstructure:"log-level"` MockBuildTags string `mapstructure:"mock-build-tags"` MockName string `mapstructure:"mockname"` PkgName string `mapstructure:"pkgname"` Packages map[string]interface{} `mapstructure:"packages"` Recursive bool `mapstructure:"recursive"` Template string `mapstructure:"template"` TemplateData map[string]any `mapstructure:"template-data"` UnrollVariadic bool `mapstructure:"unroll-variadic"` Version bool `mapstructure:"version"` // contains filtered or unexported fields }
func (*Config) CfgAsMap ¶
CfgAsMap reads in the config file and returns a map representation, instead of a struct representation. This is mainly needed because viper throws away case-sensitivity in the `packages` section, which won't work when defining interface names 😞
func (*Config) ClearCfgAsMap ¶
func (c *Config) ClearCfgAsMap()
func (*Config) ExcludePath ¶
func (*Config) GetInterfaceConfig ¶
func (*Config) GetPackageConfig ¶
GetPackageConfig returns a struct representation of the package's config as provided in yaml. If the package did not specify a config section, this method will inject the top-level config into the package's config. This is especially useful as it allows us to lazily evaluate a package's config. If the package does specify config, this method takes care to merge the top-level config with the values specified for this package.
func (*Config) GetPackages ¶
GetPackages returns a list of the packages that are defined in the `packages` config section.
func (*Config) ParseTemplates ¶
func (c *Config) ParseTemplates(ctx context.Context, iface *Interface, srcPkg *packages.Package) error
ParseTemplates parses various templated strings in the config struct into their fully defined values. This mutates the config object passed. An *Interface object can be supplied to satisfy template variables that need information about the original interface being mocked. If this argument is nil, interface-specific template variables will be set to the empty string. The srcPkg is also needed to satisfy template variables regarding the source package.
func (*Config) ShouldGenerateInterface ¶
type Interface ¶
type NodeVisitor ¶
type NodeVisitor struct {
// contains filtered or unexported fields
}
func NewNodeVisitor ¶
func NewNodeVisitor(ctx context.Context) *NodeVisitor
func (*NodeVisitor) DeclaredInterfaces ¶
func (nv *NodeVisitor) DeclaredInterfaces() []string
type TemplateGenerator ¶
type TemplateGenerator struct {
// contains filtered or unexported fields
}
func NewTemplateGenerator ¶
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
recursive_generation/subpkg_with_only_autogenerated_files
Code generated by an arbitrary code generator thingy.
|
Code generated by an arbitrary code generator thingy. |