MCPcopy Create free account
hub / github.com/nsf/gocode / find_gb_project_root

Function find_gb_project_root

utils.go:130–152  ·  view source on GitHub ↗

Code taken directly from `gb`, I hope author doesn't mind.

(path string)

Source from the content-addressed store, hash-verified

128
129// Code taken directly from `gb`, I hope author doesn't mind.
130func find_gb_project_root(path string) (string, error) {
131 path = filepath.Dir(path)
132 if path == "" {
133 return "", fmt.Errorf("project root is blank")
134 }
135 start := path
136 for path != "/" {
137 root := filepath.Join(path, "src")
138 if _, err := os.Stat(root); err != nil {
139 if os.IsNotExist(err) {
140 path = filepath.Dir(path)
141 continue
142 }
143 return "", err
144 }
145 path, err := filepath.EvalSymlinks(path)
146 if err != nil {
147 return "", err
148 }
149 return path, nil
150 }
151 return "", fmt.Errorf("could not find project root in %q or its parents", start)
152}
153
154// vendorlessImportPath returns the devendorized version of the provided import path.
155// e.g. "foo/bar/vendor/a/b" => "a/b"

Callers 1

server_auto_completeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected