1
0
Fork 0
mirror of https://github.com/imjasonh/gobinsize synced 2026-07-07 00:22:39 +00:00
No description
Find a file
Jason Hall 2bf2749a95 fix some things, generate more
Signed-off-by: Jason Hall <jason@chainguard.dev>
2025-11-18 09:42:10 -05:00
.github/workflows Strip trailing semicolons from function names and remove analyze-binaries workflow 2025-11-16 16:35:21 +00:00
treemaps fix some things, generate more 2025-11-18 09:42:10 -05:00
.gitignore Add tests, gitignore, and documentation 2025-11-16 04:05:53 +00:00
go.mod Run go fmt and go mod tidy 2025-11-17 15:40:20 +00:00
go.sum Run go fmt and go mod tidy 2025-11-17 15:40:20 +00:00
integration_test.go Fix binary naming for Windows GOOS in integration test 2025-11-16 07:43:29 +00:00
LICENSE
main.go fix some things, generate more 2025-11-18 09:42:10 -05:00
main_test.go fix some things, generate more 2025-11-18 09:42:10 -05:00
Makefile fix some things, generate more 2025-11-18 09:42:10 -05:00
README.md Update README.md 2025-11-17 11:52:35 -05:00
size.svg Add SVG treemap visualization with -svg flag 2025-11-17 15:42:56 +00:00

gobinsize

A Go program that analyzes Go binaries to determine how much of their size can be attributed to external dependencies.

Installation

go install github.com/imjasonh/gobinsize@latest

Or build from source:

git clone https://github.com/imjasonh/gobinsize.git
cd gobinsize
go build -o gobinsize .

Usage

gobinsize [-verbose] [-svg output.svg] <path-to-binary>

Options

  • -verbose: Enable verbose logging for debugging symbol attribution
  • -svg <file>: Generate an SVG treemap visualization of dependencies

Example

$ gobinsize ./myapp
Dependency Size Report
======================

github.com/gorilla/mux                               13.62 KB ( 18.8%)
gopkg.in/yaml.v2                                     52.38 KB ( 72.1%)
net                                                   6.59 KB (  9.1%)

Total size: 72.59 KB

SVG Treemap Visualization

Generate a visual treemap to see your dependencies at a glance:

$ gobinsize -svg dependencies.svg ./myapp
Dependency Size Report
======================
...
SVG treemap written to dependencies.svg

The treemap uses colors to distinguish packages and sizes rectangles proportionally to each dependency's contribution to the binary size.

How It Works

gobinsize analyzes Go binaries by:

  1. Parsing the binary's debug information (supports ELF, Mach-O, and PE formats)
  2. Extracting the Go symbol table and pclntab (program counter line table)
  3. Identifying functions and their associated packages/modules
  4. Aggregating sizes by top-level module (e.g., github.com/user/repo) or standard library package
  5. Calculating the size contribution of each dependency
  6. Generating a sorted report showing dependency sizes

Supported Platforms

  • Linux (ELF binaries)
  • macOS (Mach-O binaries)
  • Windows (PE binaries)

Notes

  • The binary must be built with Go and contain debug information
  • Size measurements are based on function code sizes from the symbol table
  • Includes all dependencies: standard library, external packages (github.com, gopkg.in, etc.), and golang.org/x packages
  • Dependencies are aggregated by module/top-level package for cleaner output