Documentation ¶
Overview ¶
Package vfsutil implements some I/O utility functions for vfs.FileSystem.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Walk ¶
Walk walks the filesystem rooted at root, calling walkFn for each file or directory in the filesystem, including root. All errors that arise visiting files and directories are filtered by walkFn. The files are walked in lexical order.
Example ¶
package main import ( "fmt" "log" "os" "github.com/shurcooL/go/vfs/godocfs/vfsutil" "golang.org/x/tools/godoc/vfs" "golang.org/x/tools/godoc/vfs/mapfs" ) func main() { var fs vfs.FileSystem = mapfs.New(map[string]string{ "zzz-last-file.txt": "It should be visited last.", "a-file.txt": "It has stuff.", "another-file.txt": "Also stuff.", "folderA/entry-A.txt": "Alpha.", "folderA/entry-B.txt": "Beta.", }) walkFn := func(path string, fi os.FileInfo, err error) error { if err != nil { log.Printf("can't stat file %s: %v\n", path, err) return nil } fmt.Println(path) return nil } err := vfsutil.Walk(fs, "/", walkFn) if err != nil { panic(err) } }
Output: / /a-file.txt /another-file.txt /folderA /folderA/entry-A.txt /folderA/entry-B.txt /zzz-last-file.txt
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.