1
0
Fork 0
mirror of https://github.com/imjasonh/slight synced 2026-07-07 00:33:20 +00:00
slight/README.md
Jason Hall ccb2a32090 license and readme
Signed-off-by: Jason Hall <jason@chainguard.dev>
2026-01-13 13:29:18 -05:00

1.2 KiB

slight

A Go vendor debloating tool that removes unused symbols from vendored dependencies.

Installation

go install github.com/imjasonh/slight/cmd/slight@latest

Usage

Analyze a project to see what could be removed:

slight analyze /path/to/project

Debloat a project (removes unused code from vendor/):

slight debloat /path/to/project

Dry run to see what would be removed:

slight debloat -dry-run /path/to/project

How it works

  1. Loads all packages with full type information using go/packages
  2. Builds an inventory of all symbols in vendor packages
  3. Analyzes usage from main code and tests to mark used symbols
  4. Computes transitive closure of dependencies
  5. Marks interface implementations to preserve polymorphic behavior
  6. Removes unused symbols and entire unused files
  7. Verifies the debloated code compiles and tests pass

Limitations

  • Build tags: Only analyzes files for the current platform
  • Reflection: May incorrectly mark symbols as unused if accessed via reflection
  • Cross-compilation: Code that cross-compiles to other platforms may break
  • Experimental: This is a demo tool, not production-ready