glob

package
v0.0.0-...-82353ca Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 14, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NFAMatchingEverything = NFA{
	// contains filtered or unexported fields
}

NFAMatchingEverything is a predeclared NFA that matches all non-empty paths.

View Source
var NFAMatchingNothing = NFA{
	// contains filtered or unexported fields
}

NFAMatchingNothing is a predeclared NFA that never matches any paths.

Functions

This section is empty.

Types

type Matcher

type Matcher struct {
	// contains filtered or unexported fields
}

Matcher of globs. Zero initialized instances correspond to an empty state machine that does not match any strings.

func (*Matcher) CopyFrom

func (m *Matcher) CopyFrom(m2 *Matcher)

CopyFrom overwrites the state of the matcher with that of another matcher. This can be used branch the matching process, or reset it to a previous state.

This function is implemented so that it reuses previously allocated memory. It is therefore recommended to reuse instances of Matcher as much as possible.

func (*Matcher) Initialize

func (m *Matcher) Initialize(nfa *NFA)

Initialize a matcher by letting it point to the initial state of a provided nondeterministic finite automaton (NFA).

func (*Matcher) IsMatch

func (m *Matcher) IsMatch() bool

IsMatch returns true if the currently parsed input corresponds to a match.

func (*Matcher) WriteRune

func (m *Matcher) WriteRune(r rune) bool

WriteRune matches a single character of pathname strings against the patterns encoded in the NFA. Upon completion, it returns whether there are still any reachable states that would allow matching to succeed. When false is returned, the caller should terminate the matching process immediately.

type NFA

type NFA struct {
	// contains filtered or unexported fields
}

NFA is a nondeterministic finite automaton of a set of glob patterns. This automaton can be used to perform matching of glob patterns against paths.

func NewNFAFromBytes

func NewNFAFromBytes(b []byte) (*NFA, error)

NewNFAFromBytes reobtains a nondeterministic finite automaton (NFA) that is capable of matching paths from a previously generated binary representation.

func NewNFAFromPatterns

func NewNFAFromPatterns(includes, excludes []string) (*NFA, error)

NewNFAFromPatterns compiles a set of glob patterns into a nondeterministic finite automaton (NFA) that is capable of matching paths.

func NewNFAFromSuffixes

func NewNFAFromSuffixes(suffixes []string) (*NFA, error)

NewNFAFromSuffixes compiles a set of filename suffixes into a nondeterministic finite automaton (NFA) that is capable of matching paths having one of the provided suffixes.

func (*NFA) Bytes

func (nfa *NFA) Bytes() []byte

Bytes returns a copy of the nondeterministic finite automaton in binary form, allowing it to be stored or transmitted.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL