walk

package
v0.0.0-...-3956967 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2016 License: GPL-3.0 Imports: 6 Imported by: 3

Documentation

Overview

walk walks one or more root paths concurrently and sends the results back via a channel. It wraps path/filepath.Walk() for people who don't want to think too much about symlinks, recursion, hidden file handling, etc.

Index

Constants

View Source
const (
	Defaults = 0
	// TODO: SeeRootLinks    = 1     // default: if root paths are symlinks they will be ignored
	// TODO: SeeLinks        = 2     // default: all symlinks (except root links) will be ignored
	// TODO: FollowLinks     = 4     // default: returns 'seen' symlinks as symlinks instead of following links
	// TODO: SeeDotFiles     = 8     // default: ignores '.' and '..' dir entries TODO
	HiddenDirs  = 16  // default: won't descend into folders starting with '.'
	HiddenFiles = 32  // default: won't return files starting with '.'
	ReturnDirs  = 64  // default: doesn't return dir paths (note: never returns root dirs)
	NoRecurse   = 128 // default: walks subdirs recursively

)

Option flags for walking; add to options to change default behaviour

Variables

This section is empty.

Functions

func FileCh

func FileCh(
	done <-chan struct{},
	errc chan<- error,
	roots []string,
	options int,
) <-chan *File

FileCh returns a file channel and walks (concurrently) all paths under each root folder in []roots, sending all regular files encountered to the channel, which is closed once all walks have completed. Walking the same file or folder twice is avoided, so for example

ch := FileCh(d, e, {"/foo", "/foo/bar"}, true)

will only walk the files in /foo/bar once. Errors are returned via the optional caller-supplied error channel. If hidden is false then hidden files and folders are ignored, unless they are members of []roots. If done is closed, FileCh() aborts the walk(s) and closes the file channel.

Types

type File

type File struct {
	Path string
	Info os.FileInfo
}

Jump to

Keyboard shortcuts

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