func main() { fs := vfs.OS("./gatefs") vfs.Walk(fs, "/", func(path string, fi os.FileInfo, err error) error { if err != nil { log.Fatal(err) } if fi.IsDir() { return nil } fmt.Println(path) return nil }) fmt.Println("Done") }
func TestFileSystem_nil(t *testing.T) { var ( fs = New("testnil") dirs []string files []string ) vfs.Walk(fs, "/", func(path string, fi os.FileInfo, err error) error { tAssertNil(t, err) if fi.IsDir() { dirs = append(dirs, path) } else { files = append(files, path) } return nil }) tAssertEQ(t, dirs, []string{"/"}) tAssertEQ(t, len(files), 0) }
func _Example() { fs := vfs.OS("./") vfs.Walk(fs, "/", func(path string, fi os.FileInfo, err error) error { if err != nil { log.Fatal(err) } if fi.IsDir() { fmt.Println("dir:", path) return nil } fmt.Println("file:", path) return nil }) fmt.Println("Done") // Output: // Done }