MCPcopy Create free account
hub / github.com/JordanCoin/codemap / detectModule

Function detectModule

scanner/filegraph.go:327–343  ·  view source on GitHub ↗

detectModule reads go.mod to find the module name

(root string)

Source from the content-addressed store, hash-verified

325
326// detectModule reads go.mod to find the module name
327func detectModule(root string) string {
328 modFile := filepath.Join(root, "go.mod")
329 f, err := os.Open(modFile)
330 if err != nil {
331 return ""
332 }
333 defer f.Close()
334
335 scanner := bufio.NewScanner(f)
336 for scanner.Scan() {
337 line := strings.TrimSpace(scanner.Text())
338 if strings.HasPrefix(line, "module ") {
339 return strings.TrimPrefix(line, "module ")
340 }
341 }
342 return ""
343}
344
345// IsHub returns true if a file has 3+ importers
346func (fg *FileGraph) IsHub(path string) bool {

Callers 3

TestDepsDetectModuleFunction · 0.85
TestDetectModuleFunction · 0.85

Calls 1

CloseMethod · 0.80

Tested by 2

TestDepsDetectModuleFunction · 0.68
TestDetectModuleFunction · 0.68