relToAny returns an import-style path (forward slashes) for abs under any root; "" if none match.
(abs string, roots []string)
| 232 | |
| 233 | // relToAny returns an import-style path (forward slashes) for abs under any root; "" if none match. |
| 234 | func relToAny(abs string, roots []string) string { |
| 235 | abs = filepath.Clean(abs) |
| 236 | for _, r := range roots { |
| 237 | r = filepath.Clean(r) |
| 238 | if rel, err := filepath.Rel(r, abs); err == nil && !strings.HasPrefix(rel, "..") && !strings.HasPrefix(filepath.ToSlash(rel), "../") { |
| 239 | return filepath.ToSlash(rel) |
| 240 | } |
| 241 | } |
| 242 | return "" |
| 243 | } |
| 244 | |
| 245 | // deriveProtoDirFromPath extracts the package from a gRPC path and searches protoInclude roots |
| 246 | // for a matching directory. This enables automatic proto directory resolution for multi-service |
no outgoing calls
no test coverage detected