Documentation
¶
Overview ¶
Package pathmatch matches slash-separated paths against glob patterns.
The syntax is path.Match applied per segment, plus "**" for "zero or more path segments". path.Match alone cannot express "**" — its "*" never crosses a separator — so the segment walk lives here rather than being open-coded by each caller.
The package is deliberately independent of the repository model: it matches strings. `find` uses it for -name/-path patterns, and pkg/source's ExcludeMatcher compiles backup exclude patterns through it — the gitignore layer (negation, directory-only, anchoring) stays there, the glob lives here, so the two cannot drift apart.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsPathPattern ¶
IsPathPattern reports whether the pattern constrains more than a basename. A caller deciding between matching a name and matching a full path uses this to make that choice from the pattern alone.
Types ¶
type Pattern ¶
type Pattern struct {
// contains filtered or unexported fields
}
Pattern is a compiled glob.
func Compile ¶
Compile parses a glob pattern. When ignoreCase is set, both the pattern and every candidate are folded to lower case before matching — which is a property of the *match*, not a claim about the case sensitivity of the filesystem the files came from.
func (*Pattern) BaseSegment ¶
BaseSegment returns the pattern's last segment when that segment can serve as a cheap basename prefilter — that is, when it is not "**", which matches any number of segments and therefore constrains the basename not at all.
This is what makes "Documents/**/*.pdf" affordable: the caller evaluates "*.pdf" against a name it already holds and resolves the full path only for the entries that survive. A pattern ending in "**" has no such prefilter, and the caller has to resolve every path.