imports
Dependency/import mapper
Scan directories for import statements across 11 languages. Returns per-file imports with type classification and a reverse index showing which files use each package.
Features
- Supports 11 languages: Go, Python, JS/TS, Zig, Rust, C/C++, Swift, Java/Kotlin, Ruby, Shell
- Import type classification: stdlib, external, local, relative, system
- Reverse index: package -> files that import it
- Auto-detects Go module from go.mod
- Recursive scanning with smart directory exclusions
Install
go install github.com/hegner123/imports@latestThe Problem: Understanding blast radius before refactoring
# You want to rename a package or move a module.
# Which files import it? How many will break?
#
# Manual approach: grep for import statements,
# parse different import syntaxes across languages,
# hope you didn't miss one.Solution
$ imports --cli --dir /path/to/project --recursive --ext .goOutput
{"files":[{"path":"main.go","language":"go","imports":[{"package":"fmt","type":"stdlib","line":3},{"package":"net/http","type":"stdlib","line":4},{"package":"myapp/pkg/handlers","type":"local","line":6}]},{"path":"handlers/user.go","language":"go","imports":[{"package":"encoding/json","type":"stdlib","line":3},{"package":"myapp/pkg/models","type":"local","line":5}]}],"packages":{"fmt":["main.go"],"net/http":["main.go"],"myapp/pkg/handlers":["main.go"],"encoding/json":["handlers/user.go"],"myapp/pkg/models":["handlers/user.go"]},"summary":{"files_scanned":2,"total_imports":5,"languages":["go"]}}Comparison
| Metric | Value |
|---|---|
| Languages supported | 11 |
| Import types classified | stdlib, external, local, relative, system |
| Reverse index | Instant lookup: package -> all importers |