filematch

package
v0.2.15 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: MPL-2.0 Imports: 6 Imported by: 0

README

filematch

Due to the Docker/Moby renaming (?) it wasn't importing correctly, so to get this to work, it was copy/pasted from Docker/Moby fileutils "github.com/docker/docker/pkg/fileutils". As a side benefit, all the non-matching (file) code was removed.

This is used in .dockerignore file parsing.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Matches

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

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

Types

type Pattern

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

Pattern defines a single regexp used to filter file paths.

func (*Pattern) Exclusion

func (p *Pattern) Exclusion() bool

Exclusion returns true if this pattern defines exclusion

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) (*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() bool

Exclusions returns true if any of the patterns define exclusions

func (*PatternMatcher) Matches

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

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

func (*PatternMatcher) Patterns

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

Patterns returns array of active patterns

Jump to

Keyboard shortcuts

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