MCPcopy
hub / github.com/go-task/task / Search

Function Search

internal/fsext/fs.go:62–82  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
62func 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

Callers 2

NewFileNodeFunction · 0.92
TestSearchFunction · 0.85

Calls 2

SearchPathFunction · 0.85
SearchPathRecursivelyFunction · 0.85

Tested by 1

TestSearchFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…