Code taken directly from `gb`, I hope author doesn't mind.
(path string)
| 128 | |
| 129 | // Code taken directly from `gb`, I hope author doesn't mind. |
| 130 | func 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" |
no outgoing calls
no test coverage detected