size does not seem to be accurate
horacimacias opened this issue · comments
First of all, thanks for sharing this tool, I found it very useful.
I've been analysing my binaries with this and I see that the sum of all sizes is much more than the final binary size.
Is there any explanation to this? is there any way to know how much smaller a certain binary will be if I remove a dependency?
The tool is still very useful to focus on the biggest contributing dependencies, but sometimes I see a dependency of 6Mb for example, and after removing it completely I see the final binary only decreased 2Mb for example. I'd like to understand where the delta comes from.
That happens because Golang does somekind of Dead Code Elimination. That removes unused variables and functions.
For instance, the net
package is reported to have 2MB. But that is only imported because net/textproto
. Because net
is not widely used, most functions/variables from net
seems to be removed. Then, removing net
imports only reduce ~100KB instead of 2MB.
I think the size must be check after the link, after the dead-code be removed. Currently, goweight
can be VERY misleading.