matcher

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package matcher provides a utility for matching files based on glob patterns, with support for excluding directories, hidden files and folders, and binary files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Globber

type Globber struct {
	// Exclude is a list of patterns that are used to exclude files.
	Exclude []string
	// Logger is a logger for debug messages (mainly).
	Logger Logger
	// contains filtered or unexported fields
}

Globber is a file matcher that compiles a list of files matching a given pattern, while excluding files based on provided exclude patterns and options.

func New

func New(hidden bool, exclude []string, logger Logger) Globber

New creates a Globber with default settings, including:

  • Excluding the executable itself
  • Excluding all kinds of executables
  • Excluding specific known directories
  • Excluding hidden folders & files if the 'hidden' parameter is set to false

The 'exclude' parameter allows specifying additional exclude patterns, and the 'logger' parameter sets the logger for debug messages.

func (*Globber) ListFiles

func (m *Globber) ListFiles() []string

ListFiles lists all files found by the Globber.

func (*Globber) Match

func (m *Globber) Match(pattern string) (err error)

Match finds all files matching the given pattern and applies the exclusion options. After running this function, the matched files can be retrieved using the ListFiles method. Returns an error if the pattern fails to match.

type Logger

type Logger interface {
	Printf(format string, v ...interface{})
}

Logger is an interface for logging formatted messages.

Jump to

Keyboard shortcuts

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