Documentation
¶
Index ¶
Constants ¶
View Source
const ( // YamlConfig is the flag for loading all packages. YamlConfig = "yaml-config" // Debug is the flag for debug logging. Debug = "debug" )
View Source
const ( DefaultMaxDepth = 100 DefaultIncludeVendor = true )
Variables ¶
View Source
var ( DefaultWrapperFunctions = []PkgFunctions{ { Pkg: "github.com/pkg/errors", Names: []string{ "New", "Errorf", "Wrap", "Wrapf", "WithStack", }, ReplaceWith: "WithMessage", ReplaceWithFormat: "WithMessagef", }, } DefaultCleanFunctions = []PkgFunctions{ {Pkg: "github.com/pkg/errors", Names: []string{ "WithMessage", "WithMessagef", }}, {Pkg: "errors", Names: []string{ "New", }}, {Pkg: "fmt", Names: []string{ "Errorf", }}, } DefaultExcludePatterns []string )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// WrapperFunctions - a list of functions that are considered to wrap errors.
// If you're using some fancy error wrapping library like github.com/pkg/errors,
// you may want to add it to this list.
// If you want to ignore some functions, don't add them to the list.
WrapperFunctions PkgsFunctions `mapstructure:"wrapperFunctions" yaml:"wrapperFunctions,omitempty"`
// CleanFunctions - a list of functions that are considered to clean errors without stacktrace.
CleanFunctions PkgsFunctions `mapstructure:"cleanFunctions" yaml:"cleanFunctions,omitempty"`
// Performance tuning options
IncludeVendor bool `mapstructure:"includeVendor" yaml:"includeVendor,omitempty"`
ExcludePatterns []string `mapstructure:"excludePatterns" yaml:"excludePatterns,omitempty"`
MaxDepth int `mapstructure:"maxDepth" yaml:"maxDepth,omitempty"`
GoRoot string `mapstructure:"-" yaml:"-"`
WorkDir string `mapstructure:"-" yaml:"-"`
Debug bool `mapstructure:"__debug" yaml:"__debug,omitempty"`
}
func NewDefaultConfig ¶
func NewDefaultConfig() *Config
func (*Config) GetDirPkgPath ¶
func (*Config) GetPkgPath ¶
type PkgFunctions ¶
type PkgsFunctions ¶
type PkgsFunctions []PkgFunctions
func (PkgsFunctions) Match ¶
func (pkgFunctions PkgsFunctions) Match(pkg, name string) bool
Match returns true if a function matches any of the package functions.
func (PkgsFunctions) ReplaceWith ¶ added in v0.3.0
func (pkgFunctions PkgsFunctions) ReplaceWith(pkg, name, text string) string
ReplaceWith returns new formatted node with replaced function name.
func (PkgsFunctions) ReplaceWithFunction ¶ added in v0.3.0
func (pkgFunctions PkgsFunctions) ReplaceWithFunction(pkg, name, text string) string
ReplaceWithFunction returns new formatted node with replaced function name.
Click to show internal directories.
Click to hide internal directories.