https://github.com/Zxilly/go-size-analyzer Skip to content Navigation Menu Toggle navigation Sign in * Product + Actions Automate any workflow + Packages Host and manage packages + Security Find and fix vulnerabilities + Codespaces Instant dev environments + GitHub Copilot Write better code with AI + Code review Manage code changes + Issues Plan and track work + Discussions Collaborate outside of code Explore + All features + Documentation + GitHub Skills + Blog * Solutions By size + Enterprise + Teams + Startups By industry + Healthcare + Financial services + Manufacturing By use case + CI/CD & Automation + DevOps + DevSecOps * Resources Topics + AI + DevOps + Security + Software Development + View all Explore + Learning Pathways + White papers, Ebooks, Webinars + Customer Stories + Partners * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles Repositories + Topics + Trending + Collections * Enterprise + Enterprise platform AI-powered developer platform Available add-ons + Advanced Security Enterprise-grade security features + GitHub Copilot Enterprise-grade AI features + Premium Support Enterprise-grade 24/7 support * Pricing Search or jump to... Search code, repositories, users, issues, pull requests... Search [ ] Clear Search syntax tips Provide feedback We read every piece of feedback, and take your input very seriously. [ ] [ ] Include my email address so I can be contacted Cancel Submit feedback Saved searches Use saved searches to filter your results more quickly Name [ ] Query [ ] To see all available qualifiers, see our documentation. Cancel Create saved search Sign in Sign up Reseting focus You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }} Zxilly / go-size-analyzer Public * Notifications You must be signed in to change notification settings * Fork 21 * Star 936 A tool for analyzing the size of compiled Go binaries, offering cross-platform support, detailed breakdowns, and multiple output formats. gsa.zxilly.dev/ License AGPL-3.0 license 936 stars 21 forks Branches Tags Activity Star Notifications You must be signed in to change notification settings * Code * Issues 3 * Pull requests 0 * Discussions * Actions * Projects 0 * Security * Insights Additional navigation options * Code * Issues * Pull requests * Discussions * Actions * Projects * Security * Insights Zxilly/go-size-analyzer This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. master BranchesTags Go to file Code Folders and files Name Name Last commit Last commit message date Latest commit History 886 Commits .devcontainer .devcontainer .github .github assets assets cmd cmd internal internal scripts scripts testdata testdata ui ui .gitignore .gitignore .golangci.yaml .golangci.yaml .goreleaser.yaml .goreleaser.yaml CODE_OF_CONDUCT.md CODE_OF_CONDUCT.md CONTRIBUTING.md CONTRIBUTING.md DEVELOPMENT.md DEVELOPMENT.md LICENSE LICENSE README.md README.md README_zh_CN.md README_zh_CN.md SECURITY.md SECURITY.md go.mod go.mod go.sum go.sum typos.toml typos.toml version.go version.go version_test.go version_test.go View all files Repository files navigation * README * Code of conduct * AGPL-3.0 license * Security go-size-analyzer Go Report Card Tests Codecov GitHub release go-recipes OpenSSF Scorecard English | Jian Ti Zhong Wen A simple tool to analyze the size of a Go compiled binary. * [*] Cross-platform support for analyzing ELF, Mach-O, and PE binary formats * [*] Detailed size breakdown by packages and sections * [*] Support multiple output formats: text, json, html, svg * [*] Interactive exploration via web interface and terminal UI * [*] Binary comparison with diff mode (supports json and text output) Installation Packaging status Download the latest binary MacOS / Linux via Homebrew: Using Homebrew brew install go-size-analyzer Windows: Using scoop scoop install go-size-analyzer Go Install: go install github.com/Zxilly/go-size-analyzer/cmd/gsa@latest Usage Example Web mode $ gsa --web golang-compiled-binary Will start a web server on port 8080, you can view the result in your browser. Or you can use the WebAssembly version in the browser: GSA Treemap Note Due to the limitation of the browser, the WebAssembly version is much slower than the native version. Normally costs 10x time to analyze the same binary. Only recommended for analysing small applications (less than 30 MB in size) The web page will look like this: image You can click to expand the package to see the details. Terminal UI $ gsa --tui golang-compiled-binary asciicast Text mode $ gsa docker-compose-linux-x86_64 +---------------------------------------------------------------------------------+ | docker-compose-linux-x86_64 | +---------+--------------------------------------------------+--------+-----------+ | PERCENT | NAME | SIZE | TYPE | +---------+--------------------------------------------------+--------+-----------+ | 17.37% | k8s.io/api | 11 MB | vendor | | 15.52% | .rodata | 9.8 MB | section | | 8.92% | .gopclntab | 5.6 MB | section | | 7.51% | .strtab | 4.7 MB | section | | 5.13% | k8s.io/client-go | 3.2 MB | vendor | | 3.36% | .symtab | 2.1 MB | section | | 3.29% | github.com/moby/buildkit | 2.1 MB | vendor | | 2.02% | google.golang.org/protobuf | 1.3 MB | vendor | | 1.96% | github.com/google/gnostic-models | 1.2 MB | vendor | | 1.82% | k8s.io/apimachinery | 1.1 MB | vendor | | 1.73% | net | 1.1 MB | std | | 1.72% | github.com/aws/aws-sdk-go-v2 | 1.1 MB | vendor | | 1.57% | crypto | 991 kB | std | | 1.53% | github.com/docker/compose/v2 | 964 kB | vendor | | 1.48% | github.com/gogo/protobuf | 931 kB | vendor | | 1.40% | runtime | 884 kB | std | | 1.32% | go.opentelemetry.io/otel | 833 kB | vendor | | 1.28% | .text | 809 kB | section | | 1.18% | google.golang.org/grpc | 742 kB | vendor | ...[Collapsed]... | 0.00% | github.com/google/shlex | 0 B | vendor | | 0.00% | github.com/pmezard/go-difflib | 0 B | vendor | | 0.00% | go.uber.org/mock | 0 B | vendor | | 0.00% | github.com/kballard/go-shellquote | 0 B | vendor | | 0.00% | tags.cncf.io/container-device-interface | 0 B | vendor | | 0.00% | github.com/josharian/intern | 0 B | vendor | | 0.00% | github.com/shibumi/go-pathspec | 0 B | vendor | | 0.00% | dario.cat/mergo | 0 B | vendor | | 0.00% | github.com/mattn/go-colorable | 0 B | vendor | | 0.00% | github.com/secure-systems-lab/go-securesystemslib| 0 B | vendor | +---------+--------------------------------------------------+--------+-----------+ | 100% | KNOWN | 63 MB | | | 100% | TOTAL | 63 MB | | +---------+--------------------------------------------------+--------+-----------+ Diff Mode $ gsa bin-linux-1.21-amd64 bin-linux-1.22-amd64 +----------------------------------------------------------------+ | Diff between bin-linux-1.21-amd64 and bin-linux-1.22-amd64 | +---------+----------------------+----------+----------+---------+ | PERCENT | NAME | OLD SIZE | NEW SIZE | DIFF | +---------+----------------------+----------+----------+---------+ | +28.69% | runtime | 801 kB | 1.0 MB | +230 kB | | +100% | internal/chacha8rand | | 3.1 kB | +3.1 kB | | +5.70% | | 18 kB | 19 kB | +1.0 kB | | +8.59% | internal/abi | 6.1 kB | 6.6 kB | +525 B | | +10.52% | internal/cpu | 4.9 kB | 5.4 kB | +515 B | | +4.45% | internal/reflectlite | 3.9 kB | 4.1 kB | +173 B | | +2.64% | internal/bytealg | 1.5 kB | 1.5 kB | +39 B | | +0.80% | strconv | 4.0 kB | 4.0 kB | +32 B | | +0.19% | syscall | 13 kB | 13 kB | +24 B | | -0.37% | embed | 8.6 kB | 8.6 kB | -32 B | | -0.16% | main | 19 kB | 19 kB | -32 B | | -0.38% | reflect | 25 kB | 25 kB | -96 B | | -0.26% | time | 87 kB | 87 kB | -224 B | | -7.95% | sync | 9.5 kB | 8.7 kB | -755 B | +---------+----------------------+----------+----------+---------+ | +8.47% | .rodata | 122 kB | 132 kB | +10 kB | | +5.04% | .gopclntab | 144 kB | 152 kB | +7.3 kB | | +3.61% | .debug_info | 168 kB | 174 kB | +6.1 kB | | +3.52% | .debug_loc | 81 kB | 84 kB | +2.9 kB | | +3.03% | .debug_line | 80 kB | 82 kB | +2.4 kB | | +3.41% | .symtab | 59 kB | 61 kB | +2.0 kB | | +4.29% | .debug_frame | 29 kB | 30 kB | +1.2 kB | | +1.25% | .strtab | 61 kB | 62 kB | +763 B | | +3.28% | .debug_ranges | 13 kB | 13 kB | +415 B | | +5.13% | .data | 5.0 kB | 5.2 kB | +256 B | | +7.32% | .typelink | 1.3 kB | 1.3 kB | +92 B | | +27.78% | .go.buildinfo | 288 B | 368 B | +80 B | | -1.56% | .debug_gdb_scripts | 64 B | 63 B | -1 B | | -0.63% | .noptrdata | 2.5 kB | 2.5 kB | -16 B | +---------+----------------------+----------+----------+---------+ | +3.86% | bin-linux-1.21-amd64 | 1.6 MB | 1.6 MB | +61 kB | | | bin-linux-1.22-amd64 | | | | +---------+----------------------+----------+----------+---------+ Svg Mode $ gsa cockroach-darwin-amd64 -f svg -o data.svg --hide-sections image Full options Usage: gsa [flags] gsa [flags] A tool for determining the extent to which dependencies contribute to the bloated size of compiled Go binaries. Arguments: Binary file to analyze or result json file for diff [] New binary file or result json file to compare, optional Flags: -h, --help Show context-sensitive help. --verbose Verbose output -f, --format="text" Output format, possible values: text,json,html,svg --no-disasm Skip disassembly pass --no-symbol Skip symbol pass --no-dwarf Skip dwarf pass -o, --output=STRING Write to file --version Show version Text output options --hide-sections Hide sections --hide-main Hide main package --hide-std Hide standard library Json output options --indent=INDENT Indentation for json output --compact Hide function details, replacement with size Svg output options --width=1028 Width of the svg treemap --height=640 Height of the svg treemap --margin-box=4 Margin between boxes --padding-box=4 Padding between box border and content --padding-root=32 Padding around root content Web interface options --web use web interface to explore the details --listen=":8080" listen address --open Open browser Terminal interface options --tui use terminal interface to explore the details Caution The tool can work with stripped binaries, but it may lead to inaccurate results. TODO * [ ] Add more pattern for disassembling the binary * [*] Extract the information from the DWARF section * [*] Count the symbol size itself to package * [ ] Add other charts like flame graph, pie chart, etc. * [ ] Support C++/Rust symbol demangling in cgo * [*] Add a TUI mode for exploring details * [*] Compile to wasm, create a ui to analyze the binary in the browser Contribution Any contribution is welcome, feel free to open an issue or a pull request. For development, see the Development Guide for more details. LICENSE Published under the AGPL-3.0. About A tool for analyzing the size of compiled Go binaries, offering cross-platform support, detailed breakdowns, and multiple output formats. gsa.zxilly.dev/ Topics react visualization go golang typescript binary analyzer treemap dependency symbol terminal-ui Resources Readme License AGPL-3.0 license Code of conduct Code of conduct Security policy Security policy Activity Stars 936 stars Watchers 4 watching Forks 21 forks Report repository Releases 61 v1.7.0 Latest Aug 28, 2024 + 60 releases Contributors 8 * * * * * * * * Languages * Go 56.2% * TypeScript 21.2% * Python 14.6% * JavaScript 7.6% * Other 0.4% Footer (c) 2024 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact * Manage cookies * Do not share my personal information You can't perform that action at this time.