Documentation ¶
Overview ¶
Package fs provides filesystem-related functions.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Walker ¶
type Walker struct {
// contains filtered or unexported fields
}
Walker provides a convenient interface for iterating over the descendants of a filesystem path. Successive calls to the Step method will step through each file or directory in the tree, including the root. The files are walked in lexical order, which makes the output deterministic but means that for very large directories Walker can be inefficient. Walker does not follow symbolic links.
Example ¶
package main import ( "fmt" "os" "github.paypal.com/jbleechersnyder/countselectcases/github.com/kr/fs" ) func main() { walker := fs.Walk("/usr/lib") for walker.Step() { if err := walker.Err(); err != nil { fmt.Fprintln(os.Stderr, err) continue } fmt.Println(walker.Path()) } }
Output:
func (*Walker) Err ¶
Err returns the error, if any, for the most recent attempt by Step to visit a file or directory. If a directory has an error, w will not descend into that directory.
func (*Walker) Path ¶
Path returns the path to the most recent file or directory visited by a call to Step. It contains the argument to Walk as a prefix; that is, if Walk is called with "dir", which is a directory containing the file "a", Path will return "dir/a".
func (*Walker) SkipDir ¶
func (w *Walker) SkipDir()
SkipDir causes the currently visited directory to be skipped. If w is not on a directory, SkipDir has no effect.