Skip to content

Latest commit

 

History

History
38 lines (27 loc) · 1.44 KB

README.md

File metadata and controls

38 lines (27 loc) · 1.44 KB

ohmyglob

A minimal glob matching utility for Go.

ohmyglob!

GoDoc Build Status

Works internally by converting glob expressions into Regexps, which are then used to match strings.

Features

  • 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

Usage

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!