On Saturday, May 18, 2019 at 1:52:43 AM UTC-4, Ian Lance Taylor wrote:
>
> On Fri, May 17, 2019 at 9:12 PM Tong Sun <sunto...@gmail.com <javascript:>> 
> wrote: 
> > 
> > How efficient Go linker is in detecting unused things (e.g., functions) 
> in a package during build and remove them from the compiled binary? 
> > 
> > To extremely simplify the case, say 
> > 
> > - I have a package that contains 10 individual functions, and each of 
> them will compile to 10K in binary size. 
> > - Then a program calls one single function from such package. 
> > 
> > Will the compiled binary executable be 10K more in size, because of 
> calling that one single function, or 100K more? 
> > 
> > I.e., will using a tiny portion of a big package cost me the whole big 
> package in compiled binary size, or only the tiny portion that I used? 
>
> The linker will discard all unused functions and variables, but will 
> not discard unused methods. 
>


Thanks, Ian 

So in other words, if a package A that I'm using is importing 10 
other packages, and as long as any of the packages' methods are used 
within package A's methods, all related methods from those 10 other 
packages will be compiled & included in the binary executable, right? 

E.g., if I'm using a package just for CLI processing, however if the 
package is doing some funky processing in its methods that use packages of 
net, net/http, net/url, all related methods from net, net/http, net/url 
will end up within my binary executable, right?

thx


-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/b42b7e71-ad55-496f-9c86-35f479b649e6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to