Skip to content
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: go help packages should document that in module mode import paths must be fully qualified #36680

Open
perillo opened this issue Jan 21, 2020 · 2 comments

Comments

@perillo
Copy link

@perillo perillo commented Jan 21, 2020

go help packages, for go1.13.6, also available at
https://golang.org/pkg/cmd/go/#hdr-Package_lists_and_patterns,
in an example about a unique prefix that belongs to you, says:

For example, paths used internally at Google all begin with 'google'

I don't know if Google is still using 'google' and GOPATH mode. However I think the documentation should say (here or somewhere else) that in module mode non fully qualified import path like 'google' are rejected by the go tool.

@toothrot toothrot changed the title go help packages: should document that in module mode import paths must be fully qualified cmd/go: go help packages should document that in module mode import paths must be fully qualified Jan 21, 2020
@toothrot
Copy link
Contributor

@toothrot toothrot commented Jan 21, 2020

The linked documentation does recommend reading go help importpath, which covers this in some detail.

Relative import paths are also supported: https://golang.org/cmd/go/#hdr-Relative_import_paths

@toothrot toothrot added this to the Backlog milestone Jan 21, 2020
@bcmills bcmills added the modules label Jan 21, 2020
@perillo
Copy link
Author

@perillo perillo commented Jan 21, 2020

Just to clarify, I'm referring to the error message emitted by go build:

cannot load google/xxx: malformed module path "google/xxx": missing dot in first path element

However, I noted that go mod init google/xxx does not report problems.
Also if in a source file inside google/xxx I import google/xxx/a, go build does not complain.

So an importpath without a dot in the first path element is allowed if it belongs to the current module, but disallowed if it belongs to an external required module. In this case the example in the documentation is valid, probably.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.