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: include line numbers in errors for bad import statements #34393

Closed
rogpeppe opened this issue Sep 19, 2019 · 2 comments
Closed

cmd/go: include line numbers in errors for bad import statements #34393

rogpeppe opened this issue Sep 19, 2019 · 2 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@rogpeppe
Copy link
Contributor

$ go version
go version go1.13 linux/amd64

Related to #12871 but more general. When a program such as this one is built, we see an error like:

build $package: cannot load string: malformed module path "string": missing dot in first path element

The problem is with at least one import statement in the package, but although it mentions the package that's being built, it's not clear where the problem might lie. It would be helpful if the error message could mention at least one exact file location that the error has occurred, enabling editors to jump to that location automatically.

@jayconrod jayconrod added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Sep 19, 2019
@jayconrod jayconrod added this to the Go1.14 milestone Sep 19, 2019
@jayconrod jayconrod added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Sep 19, 2019
@jayconrod jayconrod self-assigned this Sep 19, 2019
@jayconrod
Copy link
Contributor

This error happens when we prepare module build info (the string that go version -m prints). modload.PackageBuildInfo is trying to find a module for each import path. Paths that could not be resolved to modules (typos in this case) trigger a fatal error without position information.

@gopherbot
Copy link

Change https://golang.org/cl/196520 mentions this issue: cmd/go: don't construct module version info if there are import errors

@golang golang locked and limited conversation to collaborators Sep 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants