Documentation
¶
Overview ¶
Package walk provides high-performance filesystem traversal with advanced filtering and monitoring capabilities.
This package contains the implementation of the `stride` command, which is a high-performance file walking utility that extends the standard `filepath.Walk` functionality with concurrency, filtering, and monitoring capabilities.
Package walk provides high-performance filesystem traversal with advanced filtering and monitoring capabilities.
This package contains the implementation of the `find` command, which allows users to search for files in a given directory with advanced filtering capabilities.
The `find` command supports various options for filtering files based on name, path, size, modification time, and more. It also provides functionality to execute commands for each matched file or format the output using templates.
Package walk provides high-performance, concurrent filesystem traversal capabilities.
This package offers a powerful alternative to the standard library's filepath.Walk with additional features like concurrency, filtering, progress monitoring, and middleware support.
Index ¶
- Constants
- func CompileRegexMap(patterns map[string]string) (map[string]*regexp.Regexp, error)
- func Find(ctx context.Context, root string, opts FindOptions, handler FindHandler) error
- func FindWithExec(ctx context.Context, root string, opts FindOptions, cmdTemplate string) error
- func FindWithFormat(ctx context.Context, root string, opts FindOptions, formatTemplate string) error
- func Walk(root string, walkFn func(path string, info os.FileInfo, err error) error) error
- func WalkLimit(ctx context.Context, root string, ...) error
- func WalkLimitWithFilter(ctx context.Context, root string, ...) error
- func WalkLimitWithOptions(ctx context.Context, root string, ...) error
- func WalkLimitWithProgress(ctx context.Context, root string, ...) error
- func WalkWithAdvancedOptions(root string, walkFn AdvancedWalkFunc, options WalkOptions) error
- func WalkWithOptions(root string, walkFn WalkFunc, options WalkOptions) error
- type AdvancedWalkFunc
- type ErrorHandling
- type ErrorHandlingMode
- type FilterOptions
- type FindHandler
- type FindMessage
- type FindOptions
- type FindResult
- type LogLevel
- type MemoryLimit
- type MemoryLimitOptions
- type MiddlewareFunc
- type ProgressFn
- type Stats
- type SymlinkHandling
- type WalkFunc
- type WalkOptions
Constants ¶
const ( // Error handling modes ContinueOnError = internal.ContinueOnError StopOnError = internal.StopOnError SkipOnError = internal.SkipOnError // Symlink handling modes SymlinkFollow = internal.SymlinkFollow SymlinkIgnore = internal.SymlinkIgnore SymlinkReport = internal.SymlinkReport // Log levels LogLevelError = internal.LogLevelError LogLevelWarn = internal.LogLevelWarn LogLevelInfo = internal.LogLevelInfo LogLevelDebug = internal.LogLevelDebug // Error handling modes (string-based) ErrorHandlingContinue = internal.ErrorHandlingContinue ErrorHandlingStop = internal.ErrorHandlingStop ErrorHandlingSkip = internal.ErrorHandlingSkip )
Re-export all the constants
Variables ¶
This section is empty.
Functions ¶
func CompileRegexMap ¶
CompileRegexMap compiles a map of key-value regex patterns
func Find ¶
func Find(ctx context.Context, root string, opts FindOptions, handler FindHandler) error
Find searches for files matching the given criteria and processes them with the handler
func FindWithExec ¶
FindWithExec searches for files and executes a command for each match
func FindWithFormat ¶
func FindWithFormat(ctx context.Context, root string, opts FindOptions, formatTemplate string) error
FindWithFormat searches for files and formats output according to a template
func Walk ¶
Walk traverses the file tree rooted at root, calling walkFn for each file or directory. It's similar to filepath.Walk but with better error handling.
func WalkLimit ¶
func WalkLimit(ctx context.Context, root string, walkFn func(path string, info os.FileInfo, err error) error, limit int) error
WalkLimit traverses the file tree with a limited number of concurrent workers.
func WalkLimitWithFilter ¶
func WalkLimitWithFilter(ctx context.Context, root string, walkFn func(path string, info os.FileInfo, err error) error, limit int, filter FilterOptions) error
WalkLimitWithFilter traverses the file tree with filtering options.
func WalkLimitWithOptions ¶
func WalkLimitWithOptions(ctx context.Context, root string, walkFn func(path string, info os.FileInfo, err error) error, opts WalkOptions) error
WalkLimitWithOptions traverses the file tree with comprehensive options.
func WalkLimitWithProgress ¶
func WalkLimitWithProgress(ctx context.Context, root string, walkFn func(path string, info os.FileInfo, err error) error, limit int, progressFn ProgressFn) error
WalkLimitWithProgress traverses the file tree with progress reporting.
func WalkWithAdvancedOptions ¶
func WalkWithAdvancedOptions(root string, walkFn AdvancedWalkFunc, options WalkOptions) error
WalkWithAdvancedOptions traverses the file tree with statistics access.
func WalkWithOptions ¶
func WalkWithOptions(root string, walkFn WalkFunc, options WalkOptions) error
WalkWithOptions traverses the file tree with the enhanced context-aware API.
Types ¶
type AdvancedWalkFunc ¶
type AdvancedWalkFunc = internal.AdvancedWalkFunc
AdvancedWalkFunc includes statistics for each callback.
type ErrorHandling ¶
type ErrorHandling = internal.ErrorHandling
ErrorHandling defines how errors are handled during traversal.
type ErrorHandlingMode ¶
type ErrorHandlingMode = internal.ErrorHandlingMode
ErrorHandlingMode defines how errors are handled during traversal.
type FilterOptions ¶
type FilterOptions = internal.FilterOptions
FilterOptions defines criteria for including/excluding files and directories.
func NewFilterOptions ¶
func NewFilterOptions() FilterOptions
NewFilterOptions creates a new FilterOptions with default values.
type FindHandler ¶
type FindHandler func(ctx context.Context, result FindResult) error
FindHandler is a function that processes each found file
type FindMessage ¶
type FindMessage struct { Path string // Full path to the file Name string // Base name of the file Dir string // Directory containing the file Size int64 // Size in bytes Time time.Time // Modification time IsDir bool // Whether the entry is a directory Metadata map[string]string // File metadata Tags map[string]string // File tags VersionID string // Version identifier (if applicable) }
FindMessage holds information about a file found during traversal
type FindOptions ¶
type FindOptions struct { // Pattern matching options NamePattern string // Match by file name (supports wildcards) PathPattern string // Match by path (supports wildcards) IgnorePattern string // Skip paths matching this pattern RegexPattern *regexp.Regexp // Match by regular expression // Time-based filtering OlderThan time.Duration // Files older than this duration NewerThan time.Duration // Files newer than this duration // Size-based filtering LargerSize int64 // Files larger than this size (bytes) SmallerSize int64 // Files smaller than this size (bytes) // Metadata and tag filtering MatchMeta map[string]*regexp.Regexp // Metadata key-value patterns to match MatchTags map[string]*regexp.Regexp // Tag key-value patterns to match // Execution options ExecCmd string // Command to execute for each match PrintFormat string // Format string for output // Traversal options MaxDepth uint // Maximum directory depth to traverse FollowSymlinks bool // Whether to follow symbolic links IncludeHidden bool // Whether to include hidden files WithVersions bool // Whether to include file versions // Watch options Watch bool // Whether to watch for changes WatchEvents []string // Events to watch for (create, modify, delete) }
FindOptions defines the criteria for finding files
func NewFindOptions ¶
func NewFindOptions() FindOptions
NewFindOptions creates a new FindOptions with default values
type FindResult ¶
type FindResult struct { Message FindMessage Error error }
FindResult represents a file that matched the find criteria
type MemoryLimit ¶
type MemoryLimit = internal.MemoryLimit
MemoryLimit sets memory usage boundaries for the traversal.
type MemoryLimitOptions ¶
type MemoryLimitOptions = internal.MemoryLimitOptions
MemoryLimitOptions sets memory usage boundaries for the traversal.
type MiddlewareFunc ¶
type MiddlewareFunc = internal.MiddlewareFunc
MiddlewareFunc defines a middleware function for extensibility.
func LoggingMiddleware ¶
func LoggingMiddleware(logger *zap.Logger) MiddlewareFunc
LoggingMiddleware creates a middleware that logs file processing.
func TimingMiddleware ¶
func TimingMiddleware(threshold time.Duration) MiddlewareFunc
TimingMiddleware creates a middleware that measures processing time.
type ProgressFn ¶
type ProgressFn = internal.ProgressFn
ProgressFn is called periodically with traversal statistics.
type SymlinkHandling ¶
type SymlinkHandling = internal.SymlinkHandling
SymlinkHandling defines how symbolic links are processed.
type WalkOptions ¶
type WalkOptions = internal.WalkOptions
WalkOptions provides comprehensive configuration for the walk operation.
func NewWalkOptions ¶
func NewWalkOptions() WalkOptions
NewWalkOptions creates a new WalkOptions with default values.