Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Walk ¶
func Walk(root string, walkFn DirHandlerFunc, opts *Options) error
Walk walks the file tree rooted at root, calling walkFn for each file or directory in the tree, including root. All errors that arise visiting files and directories are filtered by walkFn. The files are walked in lexical order, which makes the output deterministic but means that for very large directories Walk can be inefficient. Walk does not follow symbolic links.
It's similar to filepath.Walk but performs breadth-first search and support Options. Unlike filepath.Walk it doesn't process SkipDir errors.
Types ¶
type DirHandlerFunc ¶
DirHandlerFunc is the type of the function called for each file or directory visited by Walk. The path argument contains the argument to Walk as a prefix; that is, if Walk is called with "dir", which is a directory containing the file "a", the walk function will be called with argument "dir/a". The info argument is the os.FileInfo for the named path.
If there was a problem walking to the file or directory named by path, the incoming error will describe the problem and the function can decide how to handle that error (and Walk will not descend into that directory). If an error is returned, processing stops.
type Options ¶
type Options struct { MaxDepth int // MaxDepth is the maximum depth of directory that are open. IgnoredDirs []string // IgnoredDirs is a list of directory names (not paths) to be ignore. IgnoreHiddenDirs bool // IngnoreHiddenDirs makes Walk ignore directory starting with ".". }
Options makes it possible to ignore certain directories.