package pattern

import "git.sr.ht/~jamesponddotco/gitignore-go/internal/pattern"

Package pattern defines the structure for a gitignore pattern.

Index

Constants

const (
	// ErrInvalidRegex is returned when a regular expression fails to compile.
	ErrInvalidRegex xerrors.Error = "invalid regex"

	// ErrScanningFile is returned when scanning a file fails for any reason.
	ErrScanningFile xerrors.Error = "failed to scan file"
)

Types

type Pattern

type Pattern struct {
	// Regex is the compiled regular expression for this pattern.
	Regex *regexp.Regexp

	// Negate indicates whether the pattern should be negated.
	Negate bool
}

Pattern represents a parsed gitignore pattern.

func Parse

func Parse(r io.Reader) ([]*Pattern, error)

Parse parses a .gitignore file into a list of patterns.

Source Files

pattern.go

Version
v1.0.0 (latest)
Published
Dec 14, 2024
Platform
linux/amd64
Imports
6 packages
Last checked
4 months ago

Tools for package owners.