SearchAll looks for files with the given possible filenames using the given entrypoint and directory. If the entrypoint is set, it checks if the entrypoint matches a file or if it matches a directory containing one of the possible filenames and add it to a list of matches. It then walks up the file
(entrypoint, dir string, possibleFilenames []string)
| 92 | // starting there. If matches are found, the absolute path to each file is added |
| 93 | // to the list and returned. |
| 94 | func SearchAll(entrypoint, dir string, possibleFilenames []string) ([]string, error) { |
| 95 | var err error |
| 96 | var entrypoints []string |
| 97 | if entrypoint != "" { |
| 98 | entrypoint, err = SearchPath(entrypoint, possibleFilenames) |
| 99 | if err != nil { |
| 100 | return nil, err |
| 101 | } |
| 102 | entrypoints = append(entrypoints, entrypoint) |
| 103 | } |
| 104 | if dir == "" { |
| 105 | dir, err = os.Getwd() |
| 106 | if err != nil { |
| 107 | return nil, err |
| 108 | } |
| 109 | } |
| 110 | paths, err := SearchNPathRecursively(dir, possibleFilenames, -1) |
| 111 | // The call to SearchNPathRecursively is ambiguous and may return |
| 112 | // os.ErrPermission if its search ends, however it may have still |
| 113 | // returned valid paths. Caller may choose to ignore that error. |
| 114 | return append(entrypoints, paths...), err |
| 115 | } |
| 116 | |
| 117 | // SearchPath will check if a file at the given path exists or not. If it does, |
| 118 | // it will return the path to it. If it does not, it will search for any files |
no test coverage detected
searching dependent graphs…