MCPcopy Create free account
hub / github.com/maruel/panicparse / isRootedIn

Function isRootedIn

stack/context.go:994–1002  ·  view source on GitHub ↗

isRootedIn returns a root if the file split in parts exists under root. Uses "/" as path separator.

(root string, parts []string)

Source from the content-addressed store, hash-verified

992//
993// Uses "/" as path separator.
994func 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.
1005var reModule = regexp.MustCompile(`(?m)^module\s+([^\n\r]+)\r?$`)

Callers 1

findRootsMethod · 0.85

Calls 2

pathJoinFunction · 0.85
isFileFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…