-1

I have a lib module planned to be used across projects. It will depend on many other modules.

But not all the projects will use functions provided by lib. I'm wondering if a project only depends on b/func B provided by lib, will it pack all the unused modules during project's build?

I understand go's smallest build unit is a pkg. In such case will ext-depency A module and ext-depency N module pack it into my project module binary?

How can I test this?

enter image description here

Luis.at.code
  • 299
  • 1
  • 3
  • 6

1 Answers1

2

But not all the projects will use functions provided by lib. I'm wondering if a project only depends on b/func B provided by lib, will it pack all the unused modules during project's build?

No.

I understand go's smallest build unit is a pkg. In such case will ext-depency A module and ext-depency N module pack it into my project module binary?

No idea what you are asking.

How can I test this?

Inspect the generated binary. (No, don't do that).

Honestly, this is a 100% non problem. Nothing to see or worry here. Forget all this. The generated binary contains what is necessary and nothing else. Unused stuff is stripped during linking.

Volker
  • 40,468
  • 7
  • 81
  • 87