Documentation ¶
Overview ¶
Package multiglob implements a multi-pattern glob matcher.
It accepts multiple glob-based patterns and produces a matcher that determines which, if any pattern matches. It's radix tree based for maximal efficiency.
Index ¶
- type Builder
- type MultiGlob
- func (mg *MultiGlob) FindAllGlobs(input string) map[string][]string
- func (mg *MultiGlob) FindAllPatterns(input string) []string
- func (mg *MultiGlob) FindGlobs(input string) (name string, globs []string, matched bool)
- func (mg *MultiGlob) FindGlobsForPattern(input, name string) (globs []string, err error)
- func (mg *MultiGlob) FindPattern(input string) (string, bool)
- func (mg *MultiGlob) Match(input string) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder builds a MultiGlob.
func (*Builder) AddPattern ¶
AddPattern adds the provided pattern to the builder and parses it.
func (*Builder) Compile ¶
Compile merges all the compiled patterns into one MultiGlob and returns it.
func (*Builder) MustAddPattern ¶
MustAddPattern wraps AddPattern, and panics if there is an error.
func (*Builder) MustCompile ¶
MustCompile wraps Compile, and panics if there is an error.
type MultiGlob ¶
type MultiGlob struct {
// contains filtered or unexported fields
}
MultiGlob is a matcher that is built from a collection of patterns. See Builder.
func (*MultiGlob) FindAllGlobs ¶ added in v0.1.1
FindAllGlobs returns a map of pattern names to globs extracted using each pattern. It uses all the patterns returned FindAllPatterns. See FindGlobs for an explanation of glob extraction.
func (*MultiGlob) FindAllPatterns ¶
FindAllPatterns returns a list containing all patterns that matched this input.
func (*MultiGlob) FindGlobs ¶ added in v0.1.1
FindGlobs finds a matching pattern using FindPattern, and then extracts the globs from the input based on that pattern. It also returns the name of the pattern matched. This uses a greedy matching algorithm. For example:
Input: "test" Pattern Found: "t*t" Globs: ["es"] Input: "pen pineapple apple pen" Pattern Found: "*apple*" Globs: ["pen pineapple ", " pen"]
func (*MultiGlob) FindGlobsForPattern ¶ added in v0.1.1
FindGlobsForPattern extracts the globs from input using the named pattern.
func (*MultiGlob) FindPattern ¶ added in v0.1.1
FindPattern returns one pattern out of the set of patterns that matches input. There is no guarantee as to which of the patterns will be returned. Returns true if a pattern was matched.