Saracen Matcher Save

Matcher is a fast path matcher/globber supporting globstar/doublestar

Project README

matcher

matcher is similar to path.Match, but:

  • Supports globstar/doublestar (**).
  • Provides a fast Glob function.
  • Supports combining matchers.

Examples

Match

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

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

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
}
Open Source Agenda is not affiliated with "Saracen Matcher" Project. README Source: saracen/matcher
Stars
52
Open Issues
0
Last Commit
1 year ago
Repository
License
MIT

Open Source Agenda Badge

Open Source Agenda Rating