Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // DiscardDirs - removes directories from output DiscardDirs = func(info Info) bool { return !info.DirEntry.IsDir() } // DiscardRegular removes regular files from output DiscardRegular = func(info Info) bool { return !info.DirEntry.Type().IsRegular() } )
Functions ¶
This section is empty.
Types ¶
type FilterFunc ¶
FilterFunc is intended to use with Filter If FilterFunc returns true then the Info is accepted as valid and forwarded to the output channel of Filter. If FilterFunc returns false then the Info is silently discarded.
type Info ¶
Info represents and entry located by fs.WalkDir Path is always relative to base path supplied to Walker for example if Walk is called with path == "/tmp" the returned entries will not contain "/tmp" in Path field.
type Walker ¶
type Walker interface { // Walk runs fs.WalkDir under the hood and returns chan of Info. // All items found by fs.WalkDir are returned as is. Basically // Walk is a custom fs.WalkDirFunc and a wrapper around WalkDir intended // to send result to a channel. It also computes lazily waiting for reader // to pull results from the channel as opposed to fs.WalkDir (fire and forget, // then wait for all recursive calls to finish). Walk(ctx context.Context, path string, funcs ...FilterFunc) <-chan Info // Err explains why chan returned by Walk was closed. If context was // cancelled or context deadline exceeded or whatewer error the // WalkDirFunc function encountered it is returned by this method. // Err will return nil if chan Info has not yet been closed. Err() error }
Walker crawls the specified path using fs.WalkDir and sends all encountered items as Info to the channel returned by Walk method.
Click to show internal directories.
Click to hide internal directories.