https://github.com/saracen/matcher
Matcher is a fast path matcher/globber supporting globstar/doublestar
https://github.com/saracen/matcher
doublestar glob globstar golang path-matcher path-matching
Last synced: 6 months ago
JSON representation
Matcher is a fast path matcher/globber supporting globstar/doublestar
- Host: GitHub
- URL: https://github.com/saracen/matcher
- Owner: saracen
- License: mit
- Created: 2020-06-07T23:14:36.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-07-14T00:55:47.000Z (almost 4 years ago)
- Last Synced: 2024-12-24T22:03:02.266Z (over 1 year ago)
- Topics: doublestar, glob, globstar, golang, path-matcher, path-matching
- Language: Go
- Homepage:
- Size: 14.6 KB
- Stars: 52
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# matcher
`matcher` is similar to `path.Match`, but:
- Supports globstar/doublestar (`**`).
- Provides a fast `Glob` function.
- Supports combining matchers.
## Examples
### Match
```golang
package main
import "github.com/saracen/matcher"
func main() {
matched, err := matcher.Match("hello/**/world", "hello/foo/bar/world")
if err != nil {
panic(err)
}
if matched {
// do something
}
}
```
### Glob
```golang
package main
import "github.com/saracen/matcher"
func main() {
matches, err := matcher.Glob(context.Background(), ".", matcher.New("**/*.go"))
if err != nil {
panic(err)
}
// do something with the matches
_ = matches
}
```
### Glob with multiple patterns
```golang
package main
import "github.com/saracen/matcher"
func main() {
matcher := matcher.Multi(
matcher.New("**/*.go"),
matcher.New("**/*.txt"))
matches, err := matcher.Glob(context.Background(), ".", matcher)
if err != nil {
panic(err)
}
// do something with the matches
_ = matches
}
```