Finds *_grpc.pb.go client methods, lists direct and transitive consumers using gopls, and shows which functions reference them.
- Requires
python3,go, andgoplsin PATH.
python3 depscan [PROJECT_ROOT]
Options:
--segments, -nNumber of leading path segments to show for transitive consumers. Default: 1--format table|tsvOutput format for the summary. Default: table--langs go|python|csharp [...]Languages to scan for callers. Default:go. Addpythonand/orcsharpto include those.--expand-top-level-pkg DIR [DIR ...]Replace functions located under these top-level dirs with their callers in the output. Default: pkg--include-testsInclude Go test files (*_test.go) in callers and function listings. Default: excluded--no-progressDisable the TTY-only Unicode progress bar during scanning.--consumer-source functions|importsHow to derive the Consumer column.functionsuses the first segment of function FQFNs (default).importsuses the import graph.--gopls-remote [ADDR]Pass-remote=autoor-remote=ADDRtogoplsto reuse a shared daemon/cache (e.g.,tcp://127.0.0.1:3737).--debug-expandPrint debug info while replacing top-level functions with callers (what gets dropped/added and what’s skipped).
By default, callers from test files are excluded. Use --include-tests to opt in.
The summary shows one row per method usage with four columns:
- Package: service/package name (e.g.,
vault,proxy_manager) - Method: method name (e.g.,
GetSecret) - Consumer: derived from
--consumer-source(default: first path segment of referencing functions) - Functions: fully-qualified function names referencing the method
In table format, rows are grouped for readability:
- Package values are shown once per group; subsequent rows omit the Package cell.
- Method values are shown once per method within the package; subsequent rows for the same method omit the Method cell.
- Consumer separators: within a method, a thin horizontal separator is drawn across Consumer→Functions when the consumer changes. Between methods, a separator spans Method→Functions. Between packages, a full-width separator is used.
In tsv format, the same four columns are output without grouping visuals.
- Progress bar: a Unicode progress bar is shown on TTYs with granular sub-steps; suppressed with
--no-progressor on non-TTY. - Test files:
*_test.goare excluded by default from callers/expansion; use--include-teststo include them. - Top-level pkg expansion: functions originating under dirs specified by
--expand-top-level-pkg(defaultpkg) are replaced by their callers. - Gopls cache reuse: use
--gopls-remoteto pointgoplsto a remote daemon (autoor explicit address) for improved performance.
You can include Python and C# callers via the --langs flag:
go(default): Usesgopls referencesfrom the generated Go gRPC stubs.python(default): Heuristic scan that looks for calls like.Method(and.Method.future(in*.pyfiles that reference the expected gRPC stub (e.g.,MyServiceStub) or import*_pb2_grpc. Functions are reported as module-relative FQFNs likepath/to/module.Class.methodorpath/to/module.function.csharp(default): Heuristic scan that looks for.Method(and.MethodAsync(in*.csfiles that reference the expected client type (e.g.,MyService.MyServiceClient). Functions are reported asNamespace.Class.Method.
Behavior and caveats:
- Tests are excluded by default;
--include-testsopts in for all languages. - The Consumer column still defaults to
functionsmode, derived from the first path segment of the function’s package/module path. Theimportsconsumer mode currently applies to Go only. - The Python/C# scans are dependency-free heuristics designed to be fast and reasonably accurate. If you need higher precision, consider integrating language servers in the future.
Examples:
# Scan Go only (default)
python3 depscan
# Include Python and C# callers
python3 depscan --langs go python csharp
# Include tests across languages
python3 depscan --langs python csharp --include-tests