Documentation ¶
Overview ¶
Package finder provides a fluent interface around Go's path/filepath.Walk
Index ¶
- func ByExtension(i, j Item) bool
- func ByModified(i, j Item) bool
- func ByName(i, j Item) bool
- func ByPath(i, j Item) bool
- func BySize(i, j Item) bool
- type Finder
- func (f *Finder) Chan() <-chan Item
- func (f *Finder) Depth(min, max int) *Finder
- func (f *Finder) Dirs() *Finder
- func (f *Finder) Each(fn func(Item))
- func (f *Finder) Error() MultiErr
- func (f *Finder) Files() *Finder
- func (f *Finder) Filter(m Matcher) *Finder
- func (f *Finder) IgnoreDots() *Finder
- func (f *Finder) IgnoreVCS() *Finder
- func (f *Finder) In(directories ...string) *Finder
- func (f *Finder) Name(n string) *Finder
- func (f *Finder) NameRegex(n string) *Finder
- func (f *Finder) NotName(n string) *Finder
- func (f *Finder) NotNameRegex(n string) *Finder
- func (f *Finder) NotPath(p string) *Finder
- func (f *Finder) Path(p string) *Finder
- func (f *Finder) Size(min, max int64) *Finder
- func (f *Finder) ToSlice() ItemSlice
- type Item
- type ItemSlice
- type Matcher
- type MultiErr
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ByExtension ¶
ByExtension sorts by file extension in ascending order.
func ByModified ¶
ByModified sorts by modification time in ascending order.
Types ¶
type Finder ¶
type Finder struct {
// contains filtered or unexported fields
}
Finder contains options for a file/directory search.
func New ¶
func New() *Finder
New returns a new finder.
By default it will search for both files and directories.
Any errors that occur during setup or walking are collected in `Finder.Error()`.
func (*Finder) Depth ¶
Depth filters based on the relative depth of the directory. Parameters min and max are one-based. Max is ignored if it's lower than min.
Depth(1, 1) // root level only Depth(2, -1) // anything deeper than root
func (*Finder) Each ¶
Each calls func fn with each found item. Any errors that occur while walking will be added to `Finder.Error()`.
func (*Finder) Filter ¶
Filter items using a custom Matcher. Signature of a matcher:
func(Item) bool
func (*Finder) IgnoreDots ¶
IgnoreDots ignores directories with a leading dot.
func (*Finder) NotNameRegex ¶
NotNameRegex excludes a file or directory name using package regexp.
func (*Finder) NotPath ¶
NotPath excludes folders from the search using gobwas/glob
p is matched against the item's RelPath() See https://github.com/gobwas/glob
func (*Finder) Path ¶
Path narrows down the folders to be searched using gobwas/glob
p is matched against the item's RelPath() See https://github.com/gobwas/glob
type Item ¶
Item represents a single file or directory.