Documentation
¶
Overview ¶
Package parallelwalkdir provides utilities to traverse a directory structure in parallel, with support for symbolic links and loop detection.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*Walker)
Option is a function type that allows configuring a Walker.
func WithContext ¶
WithContext sets the cancellation context for the walker. When the context is cancelled, the walk stops as soon as possible. If not set, defaults to context.Background() (walk runs to completion).
func WithMaxNumGoroutines ¶
WithMaxNumGoroutines allows the consumer to override the default number of parallel goroutines. If i is less than or equal to 0, the default value (2 * runtime.NumCPU()) will be used.
func WithRegexpExclude ¶
WithRegexpExclude allows the consumer to specify a regular expression. Any path (file or directory) matching this regex will be skipped and not traversed.
func WithRegexpInclude ¶
WithRegexpInclude allows the consumer to specify a regular expression that the basename of filenames must match. Only files matching the regex will be returned. This option is mutually exclusive with WithValidationFunc.
func WithSizeNotZero ¶
func WithSizeNotZero() Option
WithSizeNotZero allows the consumer to specify that only files with a size greater than 0 bytes should be returned. This option is mutually exclusive with WithValidationFunc.
func WithValidationFunc ¶
func WithValidationFunc(vf WalkDirFunc) Option
WithValidationFunc allows the consumer to specify a custom function to validate if a file should be returned. This option is mutually exclusive with WithRegexpInclude and WithSizeNotZero.
type WalkDirFunc ¶
WalkDirFunc is a function type used for custom file validation. It takes the reported path and file info, and returns true if the file should be included in the results.
type Walker ¶
type Walker struct {
// contains filtered or unexported fields
}
Walker holds the state for a parallel directory traversal. It manages concurrency, tracks visited paths to prevent loops, and returns results via a channel.
func NewWalker ¶
NewWalker creates and initializes a new Walker with default settings. It accepts a variadic list of Option functions to customize its behavior. Panics if mutually exclusive options are provided.
func (*Walker) ParallelWalk ¶
ParallelWalk starts the directory traversal from the given root path. It returns a read-only channel of strings for file paths, and a read-only channel for any errors encountered. Both channels will be closed once the entire traversal is complete or the context (set via WithContext) is cancelled.