Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MatchAnt ¶
MatchAnt reports whether s matches the given Ant-style glob pattern.
The pattern uses "/" as a segment separator. Wildcards:
- ? matches exactly one character within a single segment
- * matches zero or more characters within a single segment
- ** matches zero or more complete segments (including none)
Common uses include URL paths, file paths, config key hierarchies, and any dot- or slash-delimited namespace (e.g. "org.**.service.*").
Examples:
MatchAnt("/api/*", "/api/users") // true – single segment wildcard
MatchAnt("/api/**", "/api/v1/users") // true – multi-segment wildcard
MatchAnt("/user/?", "/user/a") // true – single char wildcard
MatchAnt("/user/?", "/user/ab") // false – ? matches exactly one char
MatchAnt("**.log", "app.service.log") // true – suffix match across segments
MatchAnt("config/*/host", "config/db/host") // true – middle segment wildcard
func MatchRegex ¶
MatchRegex reports whether path matches the given regular expression. The pattern is automatically anchored (^ and $) so partial matches are rejected. Returns false if the pattern fails to compile.
func MatchWildcard ¶
MatchWildcard reports whether s matches pattern using ? and * wildcards.
Unlike MatchAnt, this operates on a flat string with no segment semantics — * can match across any character including "/" or ".".
Useful for simple shell-style glob matching on filenames, identifiers, or any string where segment boundaries are irrelevant.
- ? matches exactly one character
- * matches zero or more characters
Examples:
MatchWildcard("foo*", "foobar") // true
MatchWildcard("f?o", "foo") // true
MatchWildcard("*.json", "data.json") // true
MatchWildcard("*.json", "a/b.json") // true – * crosses "/"
Types ¶
This section is empty.