Monday, June 16, 2025
HomeGolangDo dependencies in unused packages get compiled into binary? - Getting Assist

Do dependencies in unused packages get compiled into binary? – Getting Assist


If I develop a module with a number of packages which have third social gathering dependencies, will a go shopper that makes use of my module ALWAYS embody the dependencies of all of the packages of their binary? One other phrases, will the unused package deal dependencies of my module contribute to the dimensions of the shopper binary?

Hello, @Craig_Neuwirt,

The linker eliminates “useless code” from each libraries and your personal code. That being mentioned, there are limitations, not restricted to:

  • In case your code (or maybe these third social gathering libraries?) use the mirror package deal, you possibly can look strategies up so public strategies can’t essentially be eradicated.

  • If these third social gathering libraries register issues (like picture package deal – picture – Go Packages, or sql package deal – database/sql – Go Packages, and so forth.) then they won’t be eradicated as a result of they could be reachable from regardless of the registry is, and so forth.

In the event you’re asking, it sounds such as you may need a extra particular query to which perhaps somebody right here can provide you a extra particular reply :slight_smile:

Thanks for the data Sean. I hoped that was the case so I can keep away from multi-module repositories and Go workspaces. I work on a library known as Miruken and certainly one of its goals is to simplify the combination of different libraries by way of IoC patterns. I selected sub-packages for simplicity however don’t need pointless code bloat.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments