A minimal glob matching utility for Go.
Works internally by converting glob expressions into Regexps, which are then
used to match strings.
- Customisable separators
*matches any number of characters, but not the separator?matches any single character, but not the separator!at the beginning of a pattern will negate the match\escapes the next character –\\is a literal backslash- "Globstar" (
**) matching - Glob sets allow matching against a set of ordered globs, with precedence to later matches
import glob "github.com/obeattie/ohmyglob"
var g glob.Glob
var err error
var doesMatch bool
// Standard, with a wildcard
g, err = glob.Compile("foo/*/baz", glob.DefaultOptions)
doesMatch = g.MatchString("foo/bar/baz") // true!
doesMatch = g.MatchString("nope") // false!
// Globstar
g, err = glob.Compile("foo/**/baz", glob.DefaultOptions)
doesMatch = g.MatchString("foo/bar/bar/baz") // true!
doesMatch = g.MatchString("foo/baz") // true!
