walkFunc returns a filepath.WalkFunc which evaluates the condition tree against the given file.
(seen map[string]bool, excluder Excluder,
workFunc interface{})
| 83 | // walkFunc returns a filepath.WalkFunc which evaluates the condition tree |
| 84 | // against the given file. |
| 85 | func (q *Query) walkFunc(seen map[string]bool, excluder Excluder, |
| 86 | workFunc interface{}) filepath.WalkFunc { |
| 87 | return func(path string, info os.FileInfo, err error) error { |
| 88 | if err != nil { |
| 89 | return err |
| 90 | } |
| 91 | |
| 92 | if path == "." { |
| 93 | return nil |
| 94 | } |
| 95 | |
| 96 | // Avoid walking a single directory more than once. |
| 97 | if _, ok := seen[path]; ok { |
| 98 | return nil |
| 99 | } |
| 100 | seen[path] = true |
| 101 | |
| 102 | if excluder.shouldExclude(path) { |
| 103 | return nil |
| 104 | } |
| 105 | |
| 106 | if ok, err := q.ConditionTree.evaluateTree(path, info); err != nil { |
| 107 | return err |
| 108 | } else if !ok { |
| 109 | return nil |
| 110 | } |
| 111 | |
| 112 | results, err := q.applyModifiers(path, info) |
| 113 | if err != nil { |
| 114 | return err |
| 115 | } |
| 116 | workFunc.(func(string, os.FileInfo, map[string]interface{}))(path, info, results) |
| 117 | return nil |
| 118 | } |
| 119 | } |
no test coverage detected