Summary
In a Go module, an import of a package that has two or more non-test .go files produces no edge. --deps lists every file in that package as standalone. --importers <file> says "No files import" and reports Coverage: complete. Imports of packages with exactly one non-test file resolve correctly.
Minimal repro
go.mod module example.com/demo
single/single.go package single (1 file)
single2/impl.go package single2 (1 file, name differs from package)
multi/a.go package multi (2 files)
multi/b.go
named/named.go package named (2 files, one named after the package)
named/other.go
app/main.go imports all four packages and calls into each
go build ./... succeeds.
$ codemap --deps .
main ───▶ single/single, single2/impl
+2 standalone files # multi
+2 standalone files # named
7 files · 7 functions · 2 deps
$ codemap --importers multi/a.go .
No files import multi/a.go.
Note: files in the same package never import each other ...
Coverage: complete
It's the same for multi/b.go, named/named.go and named/other.go. single2/impl.go resolves, so the file name doesn't matter. The only thing that decides it is the file count.
Same on this repo (v4.5.1)
$ grep -rl '"codemap/watch"' . | grep '\.go$' | grep -v '^./watch/' | wc -l
21
$ codemap --importers watch/events.go .
No files import watch/events.go.
analysis/contracts.go resolves (30 importers), because analysis/ has a single non-test file.
Impact
- Hub detection, blast radius and
--importers undercount any package split across files, which is most real Go packages.
- The false negative is presented as complete coverage. "No files import X" is exactly the answer a caller acts on when deciding whether something is safe to change or delete.
Expected
An import of example.com/demo/multi links the importer to every non-test file in multi/, or to a package node that --importers expands. Either way, --importers multi/a.go lists app/main.go.
Related
#138 part 1 attributes "No files import" on Go files to same-package references not being modeled. This is a separate and larger gap: cross-package importers are also missed whenever the target package has more than one file.
Summary
In a Go module, an import of a package that has two or more non-test
.gofiles produces no edge.--depslists every file in that package as standalone.--importers <file>says "No files import" and reportsCoverage: complete. Imports of packages with exactly one non-test file resolve correctly.Minimal repro
go build ./...succeeds.It's the same for
multi/b.go,named/named.goandnamed/other.go.single2/impl.goresolves, so the file name doesn't matter. The only thing that decides it is the file count.Same on this repo (v4.5.1)
analysis/contracts.goresolves (30 importers), becauseanalysis/has a single non-test file.Impact
--importersundercount any package split across files, which is most real Go packages.Expected
An import of
example.com/demo/multilinks the importer to every non-test file inmulti/, or to a package node that--importersexpands. Either way,--importers multi/a.golistsapp/main.go.Related
#138 part 1 attributes "No files import" on Go files to same-package references not being modeled. This is a separate and larger gap: cross-package importers are also missed whenever the target package has more than one file.