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
Assignees
Labels
Milestone

Comments

@rogpeppe
Copy link
Contributor

@rogpeppe rogpeppe commented Sep 19, 2019

$ 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 this to the Go1.14 milestone Sep 19, 2019
@jayconrod jayconrod self-assigned this Sep 19, 2019
@jayconrod

This comment has been minimized.

Copy link
Contributor

@jayconrod jayconrod commented Sep 19, 2019

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

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Sep 19, 2019

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

@gopherbot gopherbot closed this in e2cbb7f Sep 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.