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: improve error message when a package does not exist #30723

Open
perillo opened this Issue Mar 11, 2019 · 4 comments

Comments

Projects
None yet
4 participants
@perillo
Copy link

perillo commented Mar 11, 2019

What did you do?

In a simple Go program I have a misspelled package import.
As an example

package main

import "logz"

What did you expect to see?

The go tool should report an error message with the file, line and column where the error occurred.
As an example:

main.go:3:2: cannot find package "logz" in any of:
	/usr/lib/go/src/logz (from $GOROOT)
	/home/manlio/.local/lib/go/src/logz (from $GOPATH)
	/home/manlio/code/src/go/src/logz

What did you see instead?

build xxx: cannot load logz: cannot find module providing package logz

There is no additional information; just the module where the problem occurred and the error message.

System details

go version go1.12 linux/amd64
GOARCH="amd64"
GOBIN="/home/manlio/.local/bin"
GOCACHE="/home/manlio/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/manlio/.local/lib/go:/home/manlio/code/src/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/go"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/manlio/code/src/python/app/lci/isosmart.it/go.mod"
GOROOT/bin/go version: go version go1.12 linux/amd64
GOROOT/bin/go tool compile -V: compile version go1.12
uname -sr: Linux 4.20.13-arch1-1-ARCH
/usr/lib/libc.so.6: GNU C Library (GNU libc) stable release version 2.28.
gdb --version: GNU gdb (GDB) 8.2.1
@perillo

This comment has been minimized.

Copy link
Author

perillo commented Mar 11, 2019

Of course the expected output should be something like:

build xxx: main.go:3:2: cannot load logz: cannot find module providing package logz

Thanks.

@perillo perillo changed the title cmd/go: improve error when a package does not exist cmd/go: improve error message when a package does not exist Mar 11, 2019

@bcmills

This comment has been minimized.

Copy link
Member

bcmills commented Mar 11, 2019

See also #30661 and #27102.

(CC @jayconrod)

@bcmills bcmills added this to the Go1.13 milestone Mar 11, 2019

@jayconrod jayconrod self-assigned this Mar 11, 2019

@manishmshiva

This comment has been minimized.

Copy link

manishmshiva commented Mar 13, 2019

Yeah. This looks far better than the original log. I can try and fix this if @jayconrod is busy.

@jayconrod

This comment has been minimized.

Copy link
Contributor

jayconrod commented Mar 13, 2019

@manishmshiva You're welcome to take a look. I'm not sure if I'll get to this for a few days.

This error is reported by the build list loading code in src/cmd/go/internal/modload/load.go. Some additional plumbing will be required to store the import positions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.