Documentation
¶
Overview ¶
Package find provides filename and path matching for finder mode.
Index ¶
Constants ¶
const TypeDir = TypeDirectory
TypeDir is an alias for TypeDirectory.
const TypeLink = TypeSymlink
TypeLink is an alias for TypeSymlink.
Variables ¶
This section is empty.
Functions ¶
func NormalizePath ¶
NormalizePath converts path separators to slash and cleans a path for matching. It preserves an absolute path's leading slash.
Types ¶
type Config ¶
type Config struct {
// Matcher controls basename or full-path matching.
Matcher MatcherConfig
// Types selects result kinds. Multiple values are ORed; an empty list keeps
// all kinds.
Types []Type
// Extensions selects file extensions without a leading dot. Multiple values
// are ORed; an empty list keeps all extensions.
Extensions []string
// MinSize is an inclusive lower bound. Zero disables the lower bound.
MinSize int64
// MaxSize is an inclusive upper bound when MaxSizeSet is true. This separate
// bit allows an explicit zero-byte limit.
MaxSize int64
// MaxSizeSet enables MaxSize.
MaxSizeSet bool
// Walk controls traversal, including hidden entries, symlinks, and depth.
Walk walk.Config
// Ignore controls hidden and ignore-file behavior during traversal.
Ignore ignore.Config
// OmitInfo leaves Result.Info nil and avoids resolving regular-file
// metadata. It cannot be combined with size filters.
OmitInfo bool
// FS selects the filesystem used by the high-level finder API. Nil uses the
// local operating-system filesystem.
FS fs.FS
}
Config holds finder matching, metadata filtering, and traversal settings. Traversal settings are passed to walk.Walker by the high-level finder API; NewFilter uses the matching and metadata fields only.
func (Config) IgnoreConfig ¶
IgnoreConfig returns the ignore and hidden-entry settings for traversal.
func (Config) WalkerConfig ¶
WalkerConfig returns the traversal settings required by finder mode. Entries that cannot satisfy the configured type or extension filters are not emitted, while matching directory and symlink entries remain available.
type Filter ¶
type Filter struct {
// contains filtered or unexported fields
}
Filter applies finder matching and metadata predicates to walk entries.
func (*Filter) Match ¶
Match reports whether entry satisfies every configured finder predicate, matching the entry's display path.
type Matcher ¶
type Matcher struct {
// contains filtered or unexported fields
}
Matcher matches finder paths without reading their contents.
A Matcher is immutable after construction and may be shared by concurrent callers.
func NewMatcher ¶
func NewMatcher(cfg MatcherConfig) (*Matcher, error)
NewMatcher compiles a finder matcher from cfg.
type MatcherConfig ¶
type MatcherConfig struct {
// Pattern is matched against a basename by default. An empty pattern
// matches every path.
Pattern string
// Glob treats Pattern as a glob expression instead of a regular expression.
Glob bool
// FixedStrings treats Pattern as a literal substring.
FixedStrings bool
// IgnoreCase enables Unicode-aware case-insensitive matching.
IgnoreCase bool
// FullPath matches the normalized path passed to Match instead of its
// basename. The caller supplies the path relative to its search root.
FullPath bool
}
MatcherConfig controls how a finder pattern is compiled.
type Result ¶
type Result struct {
// Path is the stable display path of the matched entry.
Path string
// Info is the metadata snapshot used by filters. It is nil when the
// finder is configured with Config.OmitInfo.
Info fs.FileInfo
// Kind identifies whether the result is a file or directory.
Kind walk.EntryKind
// Symlink reports whether Path itself is a symbolic link.
Symlink bool
// Depth is relative to the supplied traversal root.
Depth int
}
Result is the public, metadata-only representation of a finder match.