doc: incomplete documentation for vanity import paths in combination with Go modules #61024
Labels
Documentation
GoCommand
cmd/go
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
https://go.dev/ref/mod#vcs documents the
<meta>
tag that needs to be hosted at the module path, with the concrete example ofgolang.org/x/mod
. However, it doesn't document how the module path is determined, and which pages need to exist for that process. For example, a user can dogo get golang.org/x/mod/zip
in module mode. The documentation doesn't state whetherhttps://golang.org/x/mod/zip?go-get=1
needs to serve the meta tag or not.Some vanity paths, like
gioui.org
suggest that these subpages don't have to exist, and thatgo get
walks up the path until it gets a successful response that specifies the module path.For example,
GOPROXY=direct go get gioui.org/widget/material
sends requests to the following URLs:Out of these, only
https://gioui.org/?go-get=1
responds with a meta tag.https://pkg.go.dev/cmd/go@go1.21rc2#hdr-Remote_import_paths also contains documentation on vanity import paths, but doesn't discuss module paths. It does suggest, however, that only one request — to the full import path — is being made:
This doesn't match the actual behavior of
go get
in module mode, but it does matchgo get
in GOPATH mode. In fact, the previous example using gioui.org doesn't work in GOPATH mode, because gioui.org only serves the required meta tags for module paths, not for all possible import paths.It would be nice to clarify, in the documentation, whether one can rely on the fact that
go get
walks up the import path until it finds the module path. Assuming that one can, it would also be interesting to explore whether it's acceptable to do so, as that only works for modules, not GOPATH.The text was updated successfully, but these errors were encountered: