Hello,
I noticed that when importing the std "plugin" package then (some ?) unexported methods are kept in the binary.
Disclaimer it's something I only observed on a complex binary, I could not make a minimal reproducible example, so I'm probably misunderstanding something.
When using `-ldflags=-dumpdep` on my complex binary I was seeing something like `type:*text/template.Template -> text/template.(*Template).execute`, so just having the type `Template` makes the unexported method reachable. It disappeared when removing the "plugin" import.
We can see that if we have reflect and the binary is dynamically linked (with plugin or shared build modes), then unexported methods are also kept. Note that when `dynlink` is true then `reflectSeen` is also set to true, so I think you actually don't even need to use reflect for that to happen.
I would have expected the first part of the condition to be `m.isExported() && (d.reflectSeen || d.dynlink)` instead.
This makes binaries importing "plugin" (and probably plugins and shared builds too) significantly bigger, in my case removing the "plugin" import reduced the size of various binaries by around 30%.
Thanks !
Pierre.