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
Labels
Documentation modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@perillo
Copy link
Contributor

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

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
@toothrot toothrot added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jan 21, 2020
@perillo
Copy link
Contributor Author

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
Labels
Documentation modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants