Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewAnalyzer ¶
NewAnalyzer returns an analyzer configured exclusively through command-line flags, intended for CLI drivers (singlechecker, go vet -vettool). The processor is built lazily on the first run, after the driver has parsed the flags.
func NewAnalyzerWithConfig ¶ added in v5.0.2
NewAnalyzerWithConfig returns an analyzer configured programmatically, intended for library consumers such as golangci-lint. The configuration is copied and validated immediately; it exposes no flags, and later mutations of the passed Config have no effect.
Types ¶
type Config ¶
type Config struct {
// EnforcePatterns is a list of regular expressions to match type names that
// should be checked. Anonymous structs can be matched by '<anonymous>' alias.
//
// Each regular expression must match the full type name, including package path.
// For example, to match type `net/http.Cookie` regular expression should be
// `.*/http\.Cookie`, but not `http\.Cookie`.
EnforcePatterns Patterns `exhaustruct:"optional"`
// IgnorePatterns is a list of regular expressions to match type names that
// should be skipped from checking. Anonymous structs can be matched by
// '<anonymous>' alias.
//
// Has precedence over EnforcePatterns.
//
// Each regular expression must match the full type name, including package path.
// For example, to match type `net/http.Cookie` regular expression should be
// `.*/http\.Cookie`, but not `http\.Cookie`.
IgnorePatterns Patterns `exhaustruct:"optional"`
// OptionalPatterns is a list of regular expressions to match type names where
// all fields are treated as optional. Anonymous structs can be matched by
// '<anonymous>' alias.
//
// Each regular expression must match the full type name, including package path.
// For example, to match type `net/http.Cookie` regular expression should be
// `.*/http\.Cookie`, but not `http\.Cookie`.
OptionalPatterns Patterns `exhaustruct:"optional"`
// AllowEmpty allows empty structures, effectively excluding them from the check.
AllowEmpty bool `exhaustruct:"optional"`
// AllowEmptyPatterns is a list of regular expressions to match type names that
// should be allowed to be empty. Anonymous structs can be matched by
// '<anonymous>' alias.
//
// Each regular expression must match the full type name, including package path.
// For example, to match type `net/http.Cookie` regular expression should be
// `.*/http\.Cookie`, but not `http\.Cookie`.
AllowEmptyPatterns Patterns `exhaustruct:"optional"`
// AllowEmptyReturns allows empty structures in return statements.
AllowEmptyReturns bool `exhaustruct:"optional"`
// AllowEmptyDeclarations allows empty structures in variable declarations.
AllowEmptyDeclarations bool `exhaustruct:"optional"`
// ReportFullTypePath enables full package path in error messages instead of
// short package name. This helps when configuring include/exclude patterns,
// as import aliases can make short names ambiguous.
ReportFullTypePath bool `exhaustruct:"optional"`
// ExplicitMode enables opt-in checking. When true, only types marked with
// //exhaustruct:enforce directive or matching enforce-rx patterns are checked.
ExplicitMode bool `exhaustruct:"optional"`
}
type Patterns ¶ added in v5.0.2
type Patterns []string
Patterns is a list of regular expression patterns. It implements flag.Value, validating each value as a regular expression at flag-parse time so invalid patterns fail early.