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
copilot-swe-agent[bot] 81a19db87e Address code review feedback: improve symtab handling and readability
- Make symtab extraction failures non-fatal for modern Go binaries
- Handle cases where symtab symbols are missing or equal (empty symtab)
- Extract symtab as named constant noNextSectionRVA for better readability
- Add comments explaining that modern Go can work without separate symtab

Co-authored-by: imjasonh <210737+imjasonh@users.noreply.github.com>
2025-11-16 07:23:32 +00:00
.github/workflows Update analyze-binaries.yml 2025-11-16 02:18:58 -05:00
.gitignore Add tests, gitignore, and documentation 2025-11-16 04:05:53 +00:00
go.mod Add BuildInfo support, fix .init suffix, and address code review feedback 2025-11-16 04:58:41 +00:00
integration_test.go Update integration_test.go 2025-11-16 00:58:08 -05:00
LICENSE
main.go Address code review feedback: improve symtab handling and readability 2025-11-16 07:23:32 +00:00
main_test.go Add BuildInfo support, fix .init suffix, and address code review feedback 2025-11-16 04:58:41 +00:00
README.md Update README.md 2025-11-16 00:57:50 -05: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 <path-to-binary>

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

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