Documentation ¶
Overview ¶
Package find searches for files in a directory hierarchy recursively.
find can filter out files by file names, paths, and modes.
Index ¶
- func Find(ctx context.Context, opt ...Set) <-chan *File
- type File
- type Set
- func WithBasenameMatch(pattern string, match func(pattern string, name string) (bool, error)) Set
- func WithDebugLog(l func(string, ...interface{})) Set
- func WithFilenameMatch(pattern string) Set
- func WithModeMatch(mode, modeMask os.FileMode) Set
- func WithPathMatch(pattern string, match func(pattern string, path string) (bool, error)) Set
- func WithRegexPathMatch(pattern string) Set
- func WithRoot(rootPath string) Set
- func WithoutError() Set
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type File ¶
type File struct { // Name is the path relative to the root specified in WithRoot. Name string os.FileInfo Err error }
File is a found file.
type Set ¶
type Set func(*finder)
func WithBasenameMatch ¶
WithBasenameMatch sets up a file base name filter.
func WithDebugLog ¶
WithDebugLog logs messages to l.
func WithFilenameMatch ¶
WithFilenameMatch uses filepath.Match's shell file name matching to filter file base names.
func WithModeMatch ¶
WithModeMatch ensures only files with fileMode & modeMask == mode are returned.
func WithPathMatch ¶
WithPathMatch sets up a file path filter.
The file path passed to match will be relative to the finder's root.
func WithRegexPathMatch ¶
WithRegexPathMatch sets up a path filter using regex.
The file path passed to regexp.Match will be relative to the finder's root.
func WithRoot ¶
WithRoot sets a root path for the file finder. Only descendants of the root will be returned on the channel.
func WithoutError ¶
func WithoutError() Set
WithoutError filters out files with errors from being sent on the channel.