-
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: add option to run "go mod tidy" recursively on nested modules #40302
Comments
The And this is pretty easy to do as a for f in $(find . -name go.mod)
do (cd $(dirname $f); go mod tidy)
done |
CC @jayconrod @matloob, but I don't think this carries its weight in the |
I don't think we should support this. Go commands generally operate in the context of a specific "main" module. Running |
I understand it's quite rare. We took this approach after seeing it done in https://github.com/cucumber/godog, as the use case of having multiple modules seems to suit our needs, I seem to remember seeing it in other places too, although can't remember where right now EDIT: more examples |
I agree with Bryan. I've been doing something similar, with a bit more care about ignoring huge directories:
Then, I can just do something like: |
I also found this issue because I was searching on how to manage dependencies used only in |
For now I just made a dummy |
I think this will naturally be solved with #50745 |
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?
go mod tidy ./...
With a file structure like:
What did you expect to see?
Recursively run
go mod tidy
on subfoldersWhat did you see instead?
Although having multiple modules inside doesn't seem to be always wise for everyone, and I know some people are against it, taking the advice from https://github.com/golang/go/wiki/Modules#should-i-have-multiple-modules-in-a-single-repository, there are still cases where it is useful, and it would be good to support this option
The text was updated successfully, but these errors were encountered: