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

using build package as a dependency registers global flags on an executable #455

Closed
keegancsmith opened this issue Jan 17, 2025 · 3 comments

Comments

@keegancsmith
Copy link

This behaviour has been around for 7 years: https://github.com/mmcloughlin/avo/blame/a9457af26c1cc87edd13736b660f6f47b55c498d/build/global.go#L38

However, it leads to the command line flags in avo leaking into executables. This just happened to our project (and I expect more) since go-git uses github.com/pjbgf/sha1cd which uses avo. sha1cd project updated to avo 0.6.0 about a year ago. In particular we also defined a flag called "cpuprofile", which then lead to a runtime panic when using our tool.

See our related issue at sourcegraph/zoekt#893

@mmcloughlin
Copy link
Owner

I think the problem is that github.com/pjbgf/sha1cd should not itself depend on avo, since avo is a dev/build dependency used for code generation.

A common pattern for avo code generators is to use a separate module. The Go standard library calls these _asm, for example:

https://github.com/golang/go/blob/80bf7d83edbb48e2411d755f0636565467bb5a56/src/crypto/md5/_asm/go.mod

Other projects call it asm or avo.

@mmcloughlin
Copy link
Owner

I've posted an issue pjbgf/sha1cd#148 and a demo of what a fix might look like pjbgf/sha1cd#149. Perhaps we can continue discussion there.

@keegancsmith
Copy link
Author

I see the PR to sha1cd was merged. Following up to say thank you for the high quality work! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants