isRootedIn returns a root if the file split in parts exists under root. Uses "/" as path separator.
(root string, parts []string)
| 992 | // |
| 993 | // Uses "/" as path separator. |
| 994 | func isRootedIn(root string, parts []string) string { |
| 995 | for i := 1; i < len(parts); i++ { |
| 996 | suffix := pathJoin(parts[i:]...) |
| 997 | if isFile(pathJoin(root, suffix)) { |
| 998 | return pathJoin(parts[:i]...) |
| 999 | } |
| 1000 | } |
| 1001 | return "" |
| 1002 | } |
| 1003 | |
| 1004 | // reModule find the module line in a go.mod file. It works even on CRLF file. |
| 1005 | var reModule = regexp.MustCompile(`(?m)^module\s+([^\n\r]+)\r?$`) |