filematcher

package
v0.50.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Matches

func Matches(file string, patterns []string, opts ...Option) (bool, error)

Matches returns true if file matches any of the patterns and isn't excluded by any of the subsequent patterns.

Types

type Option

type Option func(*PatternMatcher)

An Option configures a PatternMatcher.

func WithRegexpProvider

func WithRegexpProvider(p RegexpProvider) Option

WithRegexpProvider sets a custom regexp provider.

type Pattern

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

Pattern defines a single regexp used to filter file paths.

func (*Pattern) String

func (p *Pattern) String() string

type PatternMatcher

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

PatternMatcher allows checking paths against a list of patterns.

func NewPatternMatcher

func NewPatternMatcher(patterns []string, opts ...Option) (*PatternMatcher, error)

NewPatternMatcher creates a new matcher object for specific patterns that can be used later to match against patterns against paths.

func (*PatternMatcher) Exclusions

func (pm *PatternMatcher) Exclusions() []*Pattern

Exclusions returns array of negative patterns.

func (*PatternMatcher) Matches

func (pm *PatternMatcher) Matches(file string) bool

Matches matches path against all the patterns. Matches is not safe to be called concurrently.

func (*PatternMatcher) MatchesAny

func (pm *PatternMatcher) MatchesAny(files []string) bool

func (*PatternMatcher) Patterns

func (pm *PatternMatcher) Patterns() []*Pattern

Patterns returns array of active patterns.

type RegexpProvider

type RegexpProvider func(string) (*regexp.Regexp, error)

Jump to

Keyboard shortcuts

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