fswalk

package
v0.15.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 5, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package fswalk provides facilities to process files in bulk by walking down directory trees.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddExclusions added in v0.14.4

func AddExclusions(fs *pflag.FlagSet) func() []string

AddExclusions adds exclusion parameters to the supplied flag set and returns a function that returns the specified slice

func Process

func Process(specified []string, opts Options, processor Processor) error

Process processes the specified files using the specified options and processor. It returns an error on filesystem errors or if the processor reports an error for one or more files passed to it. Specified files must be valid for processing to start.

Types

type Options

type Options struct {
	Exclusions      []string // list of excluded doublestar patterns for files
	ContinueOnError bool     // continue processing other files in the face of errors returned by the processor
	VerboseWalk     bool     // print the dir/ file being walked to stderr
	// contains filtered or unexported fields
}

Options are options for processing.

type Processor

type Processor interface {
	// Matches returns true if the specified path should be processed. The `userSpecified` argument
	// indicates that the file was explicitly passed in by the user.
	Matches(path string, file fs.FileInfo, userSpecified bool) bool
	// Process processes the specified file and returns an error in case of processing errors.
	// When processing is set to continue on errors, it is the function's responsibility to print
	// a detailed error. The bulk processor will only return an aggregate error containing stats about
	// the number of errors.
	Process(path string, file fs.FileInfo) error
}

Processor indicates whether a file matches for processing, and allows some arbitrary processing on it It is only ever given files, never directories for processing.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL