config

package
v2.31.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 10, 2023 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	All                  bool                   `mapstructure:"all"`
	BuildTags            string                 `mapstructure:"tags"`
	Case                 string                 `mapstructure:"case"`
	Config               string                 `mapstructure:"config"`
	Cpuprofile           string                 `mapstructure:"cpuprofile"`
	Dir                  string                 `mapstructure:"dir"`
	DisableConfigSearch  bool                   `mapstructure:"disable-config-search"`
	DisableVersionString bool                   `mapstructure:"disable-version-string"`
	DryRun               bool                   `mapstructure:"dry-run"`
	Exported             bool                   `mapstructure:"exported"`
	FileName             string                 `mapstructure:"filename"`
	InPackage            bool                   `mapstructure:"inpackage"`
	InPackageSuffix      bool                   `mapstructure:"inpackage-suffix"`
	KeepTree             bool                   `mapstructure:"keeptree"`
	LogLevel             string                 `mapstructure:"log-level"`
	MockName             string                 `mapstructure:"mockname"`
	Name                 string                 `mapstructure:"name"`
	Note                 string                 `mapstructure:"note"`
	Outpkg               string                 `mapstructure:"outpkg"`
	Output               string                 `mapstructure:"output"`
	Packages             map[string]interface{} `mapstructure:"packages"`
	Packageprefix        string                 `mapstructure:"packageprefix"`
	Print                bool                   `mapstructure:"print"`
	Profile              string                 `mapstructure:"profile"`
	Quiet                bool                   `mapstructure:"quiet"`
	Recursive            bool                   `mapstructure:"recursive"`
	Exclude              []string               `mapstructure:"exclude"`
	SrcPkg               string                 `mapstructure:"srcpkg"`
	BoilerplateFile      string                 `mapstructure:"boilerplate-file"`
	// StructName overrides the name given to the mock struct and should only be nonempty
	// when generating for an exact match (non regex expression in -name).
	StructName     string   `mapstructure:"structname"`
	TestOnly       bool     `mapstructure:"testonly"`
	UnrollVariadic bool     `mapstructure:"unroll-variadic"`
	Version        bool     `mapstructure:"version"`
	WithExpecter   bool     `mapstructure:"with-expecter"`
	ReplaceType    []string `mapstructure:"replace-type"`
	// contains filtered or unexported fields
}

func NewConfigFromViper

func NewConfigFromViper(v *viper.Viper) (*Config, error)

func (*Config) CfgAsMap

func (c *Config) CfgAsMap(ctx context.Context) (map[string]any, error)

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) ExcludePath

func (c *Config) ExcludePath(path string) bool

func (*Config) GetInterfaceConfig

func (c *Config) GetInterfaceConfig(ctx context.Context, packageName string, interfaceName string) ([]*Config, error)

func (*Config) GetPackageConfig

func (c *Config) GetPackageConfig(ctx context.Context, packageName string) (*Config, error)

func (*Config) GetPackages

func (c *Config) GetPackages(ctx context.Context) ([]string, error)

GetPackages returns a list of the packages that are defined in the `packages` config section.

func (*Config) Initialize

func (c *Config) Initialize(ctx context.Context) error

func (*Config) ShouldGenerateInterface

func (c *Config) ShouldGenerateInterface(ctx context.Context, packageName, interfaceName string) (bool, error)

type Interface

type Interface struct {
	Config Config `mapstructure:"config"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL