Search 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. Otherwise, it walks up the file tree starting at the given di
(entrypoint, dir string, possibleFilenames []string)
| 60 | // a match is found, the absolute path to the file is returned with its |
| 61 | // directory. If no match is found, an error is returned. |
| 62 | func Search(entrypoint, dir string, possibleFilenames []string) (string, error) { |
| 63 | var err error |
| 64 | if entrypoint != "" { |
| 65 | entrypoint, err = SearchPath(entrypoint, possibleFilenames) |
| 66 | if err != nil { |
| 67 | return "", err |
| 68 | } |
| 69 | return entrypoint, nil |
| 70 | } |
| 71 | if dir == "" { |
| 72 | dir, err = os.Getwd() |
| 73 | if err != nil { |
| 74 | return "", err |
| 75 | } |
| 76 | } |
| 77 | entrypoint, err = SearchPathRecursively(dir, possibleFilenames) |
| 78 | if err != nil { |
| 79 | return "", err |
| 80 | } |
| 81 | return entrypoint, nil |
| 82 | } |
| 83 | |
| 84 | // SearchAll looks for files with the given possible filenames using the given |
| 85 | // entrypoint and directory. If the entrypoint is set, it checks if the |
searching dependent graphs…