Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Match ¶
Match reports whether path matches the glob pattern. The pattern supports ** (recursive wildcard), * (single-level wildcard), ? (single character), and [...] (character classes). The path must use forward slashes.
For repeated matches against the same pattern, prefer Compile + Matcher.Match to avoid recompiling the regular expression on every call.
Types ¶
type Matcher ¶
type Matcher struct {
// contains filtered or unexported fields
}
Matcher is a precompiled glob pattern that can be matched against many paths without recompiling the underlying regular expression. Create one with Compile and reuse it across many Match calls.
func Compile ¶
Compile compiles a glob pattern into a reusable Matcher. The pattern supports ** (recursive wildcard), * (single-level wildcard), ? (single character), and [...] (character classes). A trailing "/" marks the pattern as directory-only (gitignore semantics): the slash is stripped and IsDirOnly returns true so callers can skip non-directory entries. The path passed to Matcher.Match must use forward slashes.
func (*Matcher) IsDirOnly ¶
IsDirOnly reports whether the pattern was suffixed with "/" (gitignore directory-only semantics). Callers should skip non-directory entries when this returns true.