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: document version tagging for modules not at the repo root #36014
Comments
I would say there are two points:
|
Another suggestion: when there are 0 tags in the |
This is valid. Modules within a repository are versioned independently. That means there needs to be a namespace of tags for each module. We accomplish that with a
Agreed. I'm working on module reference documentation for 1.14 (#33637), which will include that. It will be linked from https://golang.org/doc. I expect that will supercede a lot of information in I don't expect everyone will immediately reach for reference documentation though, since it will be long and verbose. Where would you look for this information? Would a blog post or similar article help?
Unfortunately, we can't mix those namespaces. Version tags should be permanent. If version tags are added for the root module later, they can't change the meaning for versions of non-root modules. |
Yes, a blog post or article would definitely help. When researching this issue, I ended op on the Multi-Module Repositories section of FAQ. I see now that I missed this line on my initial read:
So the information is there, but it's quite easy to miss. Also, I'm not sure if this is possible, but it might be nice if |
This is now on https://go.dev/ref/mod#vcs-version , which |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
I have not tried any newer point releases, but the code from master contains the unexpected behaviour.
What did you do?
example.org/maindir
, which contains a subdirectorysubdir
, with ago.mod
file.v0.1.0
, which was created whengo.mod
was in the main directory.v0.2.0
, which was created whengo.mod
was in the subdirectory.go get example.org/maindir/subdir
in a different modules-enabled project to add it a as a dependency.What did you expect to see?
I expected the algorithm to choose version
v0.2.0
forexample.org/maindir/subdir
.What did you see instead?
The algorithm chose
v0.0.0-20191206111401-2e6237601202
as the version.I did some digging, and apparently, when the
go.mod
file is not located in the repository root, the code that selects versions to consider filters out all tags that do not start with the path from the repo root. In this example, that means that the expected format of the tags for modules in a repository subdir issubdir/v0.2.0
. As far as I know, this is undocumented behaviour.Relevant snippet here:
go/src/cmd/go/internal/modfetch/coderepo.go
Lines 141 to 144 in 0915a19
The only reference to this behaviour I could find in the documentation is in this FAQ item: https://github.com/golang/go/wiki/Modules#is-it-possible-to-add-a-module-to-a-multi-module-repository
There, the line
git tag mig/v1.0.0
gave me the idea that this might be the issue, but it is not explained anywhere.The text was updated successfully, but these errors were encountered: