Documentation
¶
Index ¶
- Variables
- func WalkStream(ctx context.Context, root string) (<-chan SnapshotEntry, <-chan error)
- func WalkStreamWithCallback(ctx context.Context, root string, options WalkOptions, callback EntryCallback) error
- func WalkStreamWithOptions(ctx context.Context, root string, options WalkOptions) (<-chan SnapshotEntry, <-chan error)
- func WalkWithCallback(ctx context.Context, root string, options WalkOptions, callback EntryCallback) errordeprecated
- type EntryCallback
- type SnapshotEntry
- type WalkOptions
Constants ¶
This section is empty.
Variables ¶
var ErrMaxDepthReached = errors.New("maximum depth reached")
ErrMaxDepthReached is returned when the maximum depth is reached.
Functions ¶
func WalkStream ¶ added in v0.2.0
func WalkStream(ctx context.Context, root string) (<-chan SnapshotEntry, <-chan error)
WalkStream walks the file tree rooted at root and returns a channel that will receive entries as they're discovered. It uses default options.
func WalkStreamWithCallback ¶ added in v0.2.0
func WalkStreamWithCallback(ctx context.Context, root string, options WalkOptions, callback EntryCallback) error
WalkStreamWithCallback walks the file tree rooted at root and calls the callback function for each file or directory in the tree, including root. It's similar to WalkWithOptions but streams entries as they're discovered rather than collecting them all before returning.
func WalkStreamWithOptions ¶ added in v0.2.0
func WalkStreamWithOptions(ctx context.Context, root string, options WalkOptions) (<-chan SnapshotEntry, <-chan error)
WalkStreamWithOptions walks the file tree rooted at root and returns a channel that will receive entries as they're discovered. This allows processing to begin before the entire filesystem is traversed.
func WalkWithCallback
deprecated
added in
v0.2.0
func WalkWithCallback(ctx context.Context, root string, options WalkOptions, callback EntryCallback) error
WalkWithCallback is a deprecated alias for WalkStreamWithCallback. It will be removed in a future version.
Deprecated: Use WalkStreamWithCallback instead.
Types ¶
type EntryCallback ¶ added in v0.2.0
type EntryCallback func(entry SnapshotEntry) error
EntryCallback is a function that processes a SnapshotEntry. If it returns an error, the walk will be aborted.
type SnapshotEntry ¶
type SnapshotEntry struct { Path string // Relative path from the root Size int64 // Size in bytes ModTime time.Time // Modification time IsDir bool // True if it's a directory Permissions fs.FileMode // File permissions Hash string // Hash of the file content (if computed) SymlinkTarget string // Target of the symlink (if it's a symlink) Error error }
SnapshotEntry represents file metadata to be recorded.
func Walk ¶
func Walk(root string) ([]SnapshotEntry, error)
Walk performs a directory traversal with default options.
func WalkWithContext ¶
func WalkWithContext(ctx context.Context, root string) ([]SnapshotEntry, error)
WalkWithContext performs a directory traversal with context support and default options.
func WalkWithOptions ¶ added in v0.2.0
func WalkWithOptions(ctx context.Context, root string, options WalkOptions) ([]SnapshotEntry, error)
WalkWithOptions performs a directory traversal with configurable options and parallelism.
type WalkOptions ¶ added in v0.2.0
type WalkOptions struct { // ComputeHashes determines whether file hashes should be computed. ComputeHashes bool // FollowSymlinks determines whether symbolic links should be followed. FollowSymlinks bool // MaxDepth is the maximum directory depth to traverse (0 means no limit). MaxDepth int // NumWorkers specifies the number of worker goroutines for parallel processing. NumWorkers int // HashAlgorithm specifies the algorithm to be used like "BLAKE3", "MD5" etc HashAlgorithm string // SkipErrors specifies that errors should not cancel operations SkipErrors bool // ExcludePatterns is a list of filepath.Match patterns to exclude from the walk. ExcludePatterns []string // UsePartialHashing enables partial hashing for large files. UsePartialHashing bool // PartialHashingThreshold is the file size threshold in bytes above which // partial hashing will be used (if enabled). Default is 10MB. PartialHashingThreshold int64 }
WalkOptions contains options for the Walk function.
func DefaultWalkOptions ¶ added in v0.2.0
func DefaultWalkOptions() WalkOptions
DefaultWalkOptions returns the default options for Walk.