Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: build tags dependency exclusion not working #59656

Closed
bubbajoe opened this issue Apr 16, 2023 · 4 comments
Closed

cmd/go: build tags dependency exclusion not working #59656

bubbajoe opened this issue Apr 16, 2023 · 4 comments
Labels
GoCommand cmd/go WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@bubbajoe
Copy link

Description

When building my Go binary, I tried using build tags (a, b) to decrease the size of my binary. But the binary size stayed the same, even though i wasn't using the library in the build 'a'.

So I wanted to make a proposal for optimizing builds to not include the dependencies that are not in use; similar to how test dependencies can be excluding from binaries when that are in a different module.

Use Case

I have a binary which will have a bunch of features/integrations (~10 different options for now). And some clients might not need all, if any. So that could decrease the binary size by 50MB. This may be more or less depending on the libraries.

@gopherbot gopherbot added this to the Proposal milestone Apr 16, 2023
@randall77
Copy link
Contributor

This should already work. Files excluded using build tags should not even be compiled, let alone included in a binary.
Can you show us a complete example of what you are doing?

Taking out of proposal, this is either a bug or a misunderstanding of how build tags work.

@randall77 randall77 modified the milestones: Proposal, Unplanned Apr 16, 2023
@randall77 randall77 changed the title proposal: build tags dependency exclusion cmd/go: build tags dependency exclusion not working Apr 16, 2023
@seankhliao
Copy link
Member

please provide a reproducer to demonstrate the issue

@seankhliao seankhliao added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Apr 16, 2023
@bcmills bcmills added the GoCommand cmd/go label Apr 17, 2023
@bubbajoe
Copy link
Author

bubbajoe commented Apr 18, 2023

Sure, please wait.

@seankhliao seankhliao added WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. and removed WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Apr 19, 2023
@bubbajoe
Copy link
Author

Thanks guys, so it does seem to work on this smaller example: https://github.com/BubbaJoe/go-build-tag-test

Let me do some more digging to see why it's not working in my larger projects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GoCommand cmd/go WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

5 participants