-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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 install build dependencies using +build tools with modules #33696
Comments
May be somewhat related to #30515 |
Was not aware of gobin, but doesn‘t that just move the problem of installing to gobin? The go build command is already aware of all relevant path, module and tools information and should be able to find the build tools it installed without external help. Otherwise the tools build comment seems of little help? As for stringer not committed: for time being I‘ve doen it this way to make sure I don‘t forget regenerating locally and can ensure that ci and goreleaser will always have latest version of generated assets. |
You should be able to just do As for committing your generated code, not doing so can cause issues depending on the scenario (like #32720 which ended up being maxbrunsfeld/counterfeiter#126). You could also rerun |
Can you explain what you mean here?
This is indeed the main issue with The advantage FWIW, I use
https://github.com/myitcv/gobin/blob/master/README.md Regarding committing generated code/re-running
I'm going to close this as a dup of #30515. All of the points you raise are totally valid but this issue (and many others) are effectively covered by that issue, specifically this comment: #30515 (comment). |
What I meant is really #33354 (comment). I did use
in the past only to have that fail during cross-builds as the
Understood, thank you for taking the time to lay out the best practices! Again a wonderful experience with the go community. Looking at this once more I think this might even solve my problem from #33354 as the invocation of
I'll need to fully read it and maybe add |
See #33518 (comment) for proposal |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Situation: go modules enabled and
go.mod
populated. Consider build relying on go dependencies in some file:It seems the proper way to do this is/was adding these as anonymous imports:
During build, e.g. on CI, this will fail as
stringer
won't be found unless it is a) explicitly installed and b)$GOPATH/bin
is in the path.Running stringer using
go:generate go run ...
isn't a valid workaround either as that would break during cross-builds.What did you expect to see?
No error during build without additional installation and path config
What did you see instead?
build failed.
The text was updated successfully, but these errors were encountered: