cmd/go: easier go.mod updates when packages are in the same repository #50698
Labels
FrozenDueToAge
GoCommand
cmd/go
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Unfortunate
Problem
For various reasons it's not always possible to host separate go packages in different source repositories.
Thus then you have multiple packages in the same repository and there's an dependent module it takes extra commits to just manage the module versions.
ie.
Updates to
some-repo/pkg/heavy
can't updatesome-repo/cmd/foo/go.mod
directly and require two commits.Thus the workflow is:
pkg/heavy
and commit the changesome-repo/cmd/foo/go.mod
to match the result of 1.replace
directives don't really work because it breaksgo install
for that command packageIn this scenario the
cmd
package wants to continuously be in sync with thesome-repo/pkg/heavy
pkg. Which is effectively what thereplace
directive would accomplish.Solutions
The goal is for a single commit to this repository to update both modules. The solutions below are suggestions and I'm open to any bike shedding or alternatives.
1. New keyword in go.mod
It would be great to annotate the dependency
some-repo/pkg/heavy
in the cmd package module file to signal it should always be the samesha
. Thus a single commit can update both modules.One solution could be introducing a new keyword to
go.mod
In the example belowibid
denotes the dependent module is in the same repo. Thisibid
keyword is always present and never changes2. Local references allowed in require blocks
This solution might have more readability
A more succinct version could be
The text was updated successfully, but these errors were encountered: