cmd/go: add ability to allow mod tidy to ignore certain subdirectories #48859
Labels
FrozenDueToAge
GoCommand
cmd/go
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
WaitingForInfo
Issue is not actionable because of missing required information, which needs to be provided.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes? Will try later
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Context
I'm using git. I'm working on a long running new-version branch. I receive a request to patch something on
main
branch. So I quickly create a new branch frommain
. Think of it as something like this:Now in the
newver
branch there are a number of new subdirectories/subpackages etc. Because it's quite experimental, not all of the subdirectories will be staged and committed into the branch. Thus when I switch to the new branch, there are some subdirectories that are not removed (let's use for example a subpackage calledmachine
). Some are removed because they're already staged and committed tonewver
(and let's use for example, a package calledstatistics
) .What I did
So, now I'm in the
patch
branch, with some new subdirectories. I add a 2 line patch. Then I rungo mod tidy
.go mod tidy
recursively goes into each subdirectory and does its module thing. Fantastic. The issue is the code inmachine
refers to the subpackagestatistics
. Ah, now we run into a problem - it's going to be 404 not found (unrecognized import path).What I did to overcome the issue
There were two options I had:
patch
branch, go back tonewver
, make a new branch offnewver
, call itnewverexp
and add all the experimental stuff that is not ready fornewver
, then go back to the patch branch, unstash the changes, rungo mod tidy
and push changes. Outcome: I now have more branches to manage!go mod tidy
and then restore them from backup.Either way, both options took more time than expected. Now, you might say "this is just your poor git hygiene". And I'd be inclined to agree with you.
What would be nicer
It would make things a lot more expedient if I could just tell
go mod tidy
to not recursively go into certain directories that has.go
files in them because:The text was updated successfully, but these errors were encountered: