-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/go: 'go build' sets arbitrary requirement of module name containing dots #27503
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
Comments
It's not totally arbitrary. Dotless paths in general are reserved for the standard library; (It's also kind of weird to use names like
It may be the case that you'd need to update lots of repositories, but it's not obvious to me why that would have to be atomic. Now that Go has type aliases, it is generally straightforward to define one package as a thin forwarding shim for another; with semantic import paths, we should probably even write a tool to automate construction of those shims, because I expect it will be common to define The general migration process would be:
|
@bcmills @rsc Thinking about this some more, the assertion that a hostname must contain dots is not even correct. https://tools.ietf.org/html/rfc952
Furthermore, with this assertion, the go1.X compiler will no longer be compliant with the Go1 BNF
Welcome to about 6 years ago, to a huge source tree that predates the GOVENDOR experiment, and an internal package system that was usable with private and authenticated VCSs. We are very much looking forward to relieving years of pain with Go modules, but understandably the transition isn't painless, due to quirks like this one. |
The BNF isn't the entire spec. The relevant clause is this one (emphasis mine):
In this case, you can think of the universe of modules as the “repository of installed packages”, and the dotted-domain restriction ensures that module paths do not collide. (It is possible that we'll revisit that requirement in light of the local-proxy use case, but I'm not sure either way. For what it's worth, Google also has a substantial body of code using non-domain-prefixed import paths.) |
FWIW we've got this patched version of go1.11 that we're using internally now which removes the "hostname" check. Our internal GOPROXY is the source of truth for managing namespaces, not As a side note we do plan on migrating away from the dot-less |
We want to allow experimentation, so we're not categorically cutting off all module statements in all contexts without dots, but anything that has to get resolved through downloading needs a dot and more generally should have a fully qualified domain name. That's how we've carved the name space between standard library and external things. I understand that pedantically the RFCs don't require dots but that's the separation we've used from very very early on with goinstall and later go get. |
Sorry, but if we ever thought "indeed" (an ordinary English word!) were a great name for a standard library package, then you'd have a problem. I would encourage you as part of adopting modules to change your import paths to indeed.com or some other name that is unambiguously under your control. |
All of my dependent modules are in order, and none of them have a hostname prefix that contain dots. The convention we have been using for years with GOPATH is "company/foo/bar", rather than "our.company.com/foo/bar".
What version of Go are you using (
go version
)?What did you do?
Built a proxy which can be used to serve up modules which reflect our real world, which is a world with custom import paths with no "hostname" prefix. Trying to use
go build
with this proxy and our modules results in thego build
command complaining that our modules do not start with a "hostname" prefix, because the first path element in our modules do not contain any dot characters.First, a view of the modules being served by our proxy
This seems like a reasonable module structure.
A peek at the
go.mod
file we are about to use:Lines up fine with the modules being served from the proxy.
Okay let's build it
Hmm, that's not useful. The
go build
command is enforcing import paths to begin with a path element that contains dot characters. This seems totally arbitrary (at least in the context of GOPROXY) and breaks at least this one real world use case (a fix on our end would be "atomically" updating hundreds of repositories and interrupting dozens of developer workflows).It seems to me at least with GOPROXY set,
go build
should just trust that the module will be resolvable.The text was updated successfully, but these errors were encountered: