Documentation ¶
Overview ¶
Package wcmatch implements wildcard matching files using .gitignore syntax.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*Options)
Option supports the functional option pattern for NewWildcardMatcher.
func BaseDir ¶
BaseDir is used to set the base directory to use when creating a WildcardMatcher. Providing a base dir here means the matcher will not match anything outside of that directory.
Examples: The pattern 'a.txt' with the base dir '/my/base' is equivalent to the pattern '/my/base/**/a.txt' without a base dir.
The pattern '/a.txt' with the base dir '/my/base/ is equivalent to the pattern '/my/base/a.txt' without a base dir.
func IgnoreCase ¶
IgnoreCase is used to enable/disable case-insensitive operation when creating a WildcardMatcher.
type WildcardMatcher ¶
type WildcardMatcher struct {
// contains filtered or unexported fields
}
WildcardMatcher represents a wildcard-pattern (in .gitignore syntax) and options used to match against file paths.
func NewWildcardMatcher ¶
func NewWildcardMatcher(pattern string, options ...Option) (matcher *WildcardMatcher, err error)
NewWildcardMatcher creates a new WildcardMatcher with the specified pattern and options. The default option is for the matcher to be case-sensitive without a base dir. nolint:funlen,gocognit,gocyclo,cyclop,maintidx
func (*WildcardMatcher) Match ¶
func (matcher *WildcardMatcher) Match(text string, isDir bool) bool
Match matches the specified text against the pattern of this WildcardMatcher. Returns true if it is a match, and false if it is not. isDir should be set to true to indicate that the specified text is a directory, and false if it is a file.
func (*WildcardMatcher) Negated ¶
func (matcher *WildcardMatcher) Negated() bool
Negated inidicates whether the pattern used by this matcher is a negated pattern, i.e. starts with a '!'.
func (*WildcardMatcher) Options ¶
func (matcher *WildcardMatcher) Options() Options
Options gets the options used when constructing the WildcardMatcher.
func (*WildcardMatcher) Pattern ¶
func (matcher *WildcardMatcher) Pattern() string
Pattern returns the original pattern from which this matcher was created.