Documentation
¶
Overview ¶
Package matches provides utilities for searching and matching things.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PathMatcher ¶
type PathMatcher interface {
// Match checks if the path matches and returns true if it does
Match(path string) (bool, error)
}
PathMatcher is used to determine if a file system path matches.
type RegexList ¶
type RegexList struct {
// contains filtered or unexported fields
}
A list of compiled regular expressions that can be used to match things.
func NewRegexList ¶
Create a new RegexList that compiles the given regular expressions.
func (*RegexList) Matches ¶
Returns the slice of needles that matched any of the compiled regular expressions.
func (*RegexList) MatchesAll ¶
Returns true if the needle matches all of the compiled regular expressions.
func (*RegexList) MatchesAny ¶
Returns true if the needle matches any of the compiled regular expressions.
type RegexListCompileErr ¶
func (*RegexListCompileErr) Error ¶
func (e *RegexListCompileErr) Error() string
type RegexPathMatcher ¶
type RegexPathMatcher struct {
// contains filtered or unexported fields
}
RegexPathMatcher will match a file system path against a set of regular expressions.
func NewRegexPathMatcher ¶
func NewRegexPathMatcher(expressions []string) (*RegexPathMatcher, error)
Create a new RegexPathMatcher using the regular expression patterns.
type RegexScanner ¶
type RegexScanner struct {
// contains filtered or unexported fields
}
RegexScanner is used to read from an io.Reader line by line and then tries to match the line against a set of regular expressions.
func (*RegexScanner) Add ¶
func (r *RegexScanner) Add(key string, expression string, foundFn RegexScannerFoundMatches) error
Register a regular expression that will try and find matches when the Process function is called NOTE: To match case-insensitive add the prefix (?i) to the regular expression.
func (*RegexScanner) Process ¶
func (r *RegexScanner) Process(rd io.Reader) (RegexScannerResult, error)
Read line by line from the io.Reader and try and find matching regular expressions. The read line will be written to any writter set by SetOut method.
func (*RegexScanner) SetOut ¶
func (r *RegexScanner) SetOut(w io.Writer)
Set the io.Writer that will be used to write any line read from the io.Reader during the Process method. Useful for debugging.
type RegexScannerFoundMatches ¶
Function that will be called when a regular expression found some matches.
type RegexScannerResult ¶
Result from the Process function. A map of the key to matching substrings. NOTE: The result will always contain the last found match for a key (meaning the map is updated on each find).
type ShellPatternPathMatcher ¶
type ShellPatternPathMatcher struct {
// contains filtered or unexported fields
}
ShellPatternPathMatcher will match a file system path against a set of shell patterns. See https://pkg.go.dev/path/filepath#Match for details.
func NewShellPatternPathMatcher ¶
func NewShellPatternPathMatcher(patterns []string) *ShellPatternPathMatcher
Create a new ShellPatternPathMatcher using the shell patterns.