Most project comes with dependencies.
Go is quite interesting as the compiler only ships the needed code.
Think about node
, it's definitely not the same and the its node_modules
folder…
Let's go back to Go, so the compiler "imports" only what is needed.
But we were facing a lack of tooling easy to understand to estimate the consequences of dependencies.
Until recently, and this wonderful project and tool:
Zxilly / go-size-analyzer
A tool for analyzing the size of compiled Go binaries, offering cross-platform support, detailed breakdowns, and multiple output formats.
go-size-analyzer
English | 简体中文
A simple tool to analyze the size of a Go compiled binary.
-
Cross-platform support for analyzing
ELF
,Mach-O
, andPE
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
andtext
output)
Installation
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…
A tool for analysing the size of dependencies in compiled Golang binaries, providing insight into their impact on the final build.
Kudos @zxilly (I'm unsure you are active on Dev.to), but thanks
Top comments (0)