config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2025 License: MIT Imports: 11 Imported by: 0

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

Variables

View Source
var (
	DefaultWrapperFunctions = []PkgFunctions{
		{Pkg: "github.com/pkg/errors", Names: []string{
			"New", "Errorf", "Wrap", "Wrapf", "WithStack",
		}},
	}
	DefaultCleanFunctions = []PkgFunctions{
		{Pkg: "github.com/pkg/errors", Names: []string{
			"WithMessage", "WithMessagef",
		}},
		{Pkg: "errors", Names: []string{
			"New", "Wrapf", "WithStack",
		}},
		{Pkg: "fmt", Names: []string{
			"Errorf",
		}},
	}
)
View Source
var Analyzer = &analysis.Analyzer{
	Name:       "errstack_config",
	Doc:        _doc,
	Run:        helpers.WrapRun(run),
	Flags:      newFlagSet(),
	ResultType: reflect.TypeOf((*helpers.Result[*Config])(nil)),
}

Functions

This section is empty.

Types

type Config

type Config struct {
	// WrapperFunctions - 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, simply don't add them to the list.
	WrapperFunctions PkgsFunctions `mapstructure:"wrapperFunctions" yaml:"wrapperFunctions,omitempty"`
	// CleanFunctions - list of functions that are considered to clean errors without stacktrace.
	CleanFunctions PkgsFunctions `mapstructure:"cleanFunctions" yaml:"cleanFunctions,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 (cfg *Config) GetDirPkgPath(dir string) string

func (*Config) GetPkgPath

func (cfg *Config) GetPkgPath(dir string) string

type PkgFunctions

type PkgFunctions struct {
	Pkg   string   `mapstructure:"pkg" yaml:"pkg"`
	Names []string `mapstructure:"names" yaml:"names"`
}

type PkgsFunctions

type PkgsFunctions []PkgFunctions

func (PkgsFunctions) Match

func (pkgFunctions PkgsFunctions) Match(pkg, name string) bool

Match returns true if function matches any of package functions.

Jump to

Keyboard shortcuts

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