FindFiles creates a pipe listing all the files in the directory dir and its subdirectories recursively, one per line, like Unix find(1). Errors are ignored unless no files are found (in which case the pipe's error status will be set to the last error encountered). Each line of the output consists o
(dir string)
| 93 | // test/1.txt |
| 94 | // test/2.txt |
| 95 | func FindFiles(dir string) *Pipe { |
| 96 | var paths []string |
| 97 | var innerErr error |
| 98 | fs.WalkDir(os.DirFS(dir), ".", func(path string, d fs.DirEntry, err error) error { |
| 99 | if err != nil { |
| 100 | innerErr = err |
| 101 | return fs.SkipDir |
| 102 | } |
| 103 | if !d.IsDir() { |
| 104 | paths = append(paths, filepath.Join(dir, path)) |
| 105 | } |
| 106 | return nil |
| 107 | }) |
| 108 | if innerErr != nil && len(paths) == 0 { |
| 109 | return NewPipe().WithError(innerErr) |
| 110 | } |
| 111 | return Slice(paths) |
| 112 | } |
| 113 | |
| 114 | // Get creates a pipe that makes an HTTP GET request to url, and produces the |
| 115 | // response. See [Pipe.Do] for how the HTTP response status is interpreted. |
searching dependent graphs…