Deadmono provides powerful dead code detection across Go monorepos, identifying unreachable functions spanning multiple entrypoints. It enhances the existing deadcode tool, making it adaptable for diverse Go projects. Streamline code maintenance and improve project quality by highlighting unused code, even within shared internal SDKs.
Deadmono: Efficient Dead Code Detection in Go Monorepos
deadmono is a specialized tool designed to identify unreachable functions within Go monorepos, thereby enhancing code quality and maintainability. By extending the capabilities of the deadcode tool, deadmono effectively operates across multiple entry points, making it particularly suited for projects that house several main packages.
While deadmono is optimized for monorepos, it is versatile enough to be utilized in any Go project containing multiple entry points. It serves an essential function in recognizing dead code in shared internal SDKs across different services by employing the -filter flag for tailored analysis.
deadmono calculates intersections based on imported packages, ensuring accurate reporting of truly dead functions.To analyze multiple entry points in a monorepo, the command is:
deadmono [flags] path/to/main1.go path/to/main2.go ...
For instance, to examine three services:
deadmono services/authn/main.go services/config/main.go services/healthcheck/main.go
This command will report any functions that remain unused by all specified services.
-test: Include test executables in the analysis.-generated: Consider dead functions found in generated Go files.-tags string: Specify build tags for the analysis.-filter string: Use a regular expression to limit package analysis scope.-json: Output results in JSON format to integrate with other tools.-debug: Enable verbose output for debugging purposes.Analyzing dead code across multiple services in a monorepo poses significant challenges. Traditional methods that simply run a dead code analysis on each service may lead to inaccurate results, particularly when services do not import certain shared packages, resulting in missed dead functions. deadmono resolves this issue through systematic package-based intersection analysis, ensuring accurate identification of all dead code.
By tracking which packages are imported by each service and analyzing them accordingly, deadmono ensures that results reflect only the genuinely unused code.
While deadmono provides valuable analysis capabilities, users should be aware of its limitations inherited from the deadcode tool, including:
//go:linkname directives.Refer to the deadcode documentation for more comprehensive insights into the analysis process.
Open contributions are encouraged to enhance the capabilities on deadmono. Community engagement through Pull Requests is welcomed to broaden the tool's functionality.
No comments yet.
Sign in to be the first to comment.