Documentation ¶
Overview ¶
Package ohmyglob provides a minimal glob matching utility.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // Logger is used to log trace-level info; logging is completely disabled by default but can be changed by replacing // this with a configured logger Logger log.LoggerInterface // Escaper is the character used to escape a meaningful character Escaper = '\\' )
var DefaultOptions = &Options{ Separator: '/', MatchAtStart: true, MatchAtEnd: true, }
DefaultOptions are a default set of Options that uses a forward slash as a separator, and require a full match
Functions ¶
func EscapeGlobComponent ¶
EscapeGlobComponent returns an escaped version of the passed string, ensuring a literal match when used in a pattern.
func EscapeGlobString ¶
EscapeGlobString returns an escaped version of the passed string, ensuring a literal match of its components. As distinct to EscapeGlobComponent, it will not escape the separator
Types ¶
type Glob ¶
type Glob interface { GlobMatcher // String returns the pattern that was used to create the Glob String() string // IsNegative returns whether the pattern was negated (prefixed with !) IsNegative() bool }
Glob is a single glob pattern; implements GlobMatcher. A Glob is immutable.
type GlobMatcher ¶
type GlobMatcher interface { // Match reports whether the Glob matches the byte slice b Match(b []byte) bool // MatchReader reports whether the Glob matches the text read by the RuneReader MatchReader(r io.RuneReader) bool // MatchString reports whether the Glob matches the string s MatchString(s string) bool }
GlobMatcher is the basic interface of a Glob or GlobSet. It provides a Regexp-style interface for checking matches.
type GlobSet ¶
type GlobSet interface { GlobMatcher // Globs returns the ordered Glob objects contained within the set Globs() []Glob // String returns the patterns used to create the GlobSet String() string // MatchingGlob returns the Glob that matches the specified pattern (or does not match, in the case of a negative // glob) MatchingGlob(b []byte) Glob // AllMatchingGlobs returns all Globs that match the specified pattern (or do not match, in the case of a negative // glob) AllMatchingGlobs(b []byte) []Glob }
GlobSet represents an ordered set of Globs, and has the same matching capabilities as a Glob. Globbing is done in order, with later globs taking precedence over earlier globs in the set. A GlobSet is immutable.
func CompileGlobSet ¶
CompileGlobSet constructs a GlobSet from a slice of strings, which will be compiled individually to Globs.
func NewGlobSet ¶
NewGlobSet constructs a GlobSet from a slice of Globs.