MCPcopy Create free account
hub / github.com/kataras/iris / walk

Function walk

view/fs.go:12–51  ·  view source on GitHub ↗

walk recursively in "fileSystem" descends "root" path, calling "walkFn".

(fileSystem fs.FS, root string, walkFn filepath.WalkFunc)

Source from the content-addressed store, hash-verified

10
11// walk recursively in "fileSystem" descends "root" path, calling "walkFn".
12func walk(fileSystem fs.FS, root string, walkFn filepath.WalkFunc) error {
13 if root != "" && root != "/" && root != "." {
14 sub, err := fs.Sub(fileSystem, root)
15 if err != nil {
16 return err
17 }
18 fileSystem = sub
19 }
20
21 if root == "" {
22 root = "."
23 }
24
25 return fs.WalkDir(fileSystem, root, func(path string, d fs.DirEntry, err error) error {
26 if err != nil {
27 return fmt.Errorf("walk: %s: %w", path, err)
28 }
29
30 info, err := d.Info()
31 if err != nil {
32 if err != filepath.SkipDir {
33 return fmt.Errorf("walk stat: %s: %w", path, err)
34 }
35
36 return nil
37 }
38
39 if info.IsDir() {
40 return nil
41 }
42
43 walkFnErr := walkFn(path, info, err)
44 if walkFnErr != nil {
45 return fmt.Errorf("walk: walkFn: %w", walkFnErr)
46 }
47
48 return nil
49 })
50
51}
52
53func asset(fileSystem fs.FS, name string) ([]byte, error) {
54 data, err := fs.ReadFile(fileSystem, name)

Callers 4

LoadMethod · 0.85
loadMethod · 0.85
LoadMethod · 0.85
LoadMethod · 0.85

Calls 3

SubMethod · 0.80
ErrorfMethod · 0.80
IsDirMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…