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: error message refers to "." instead of the path provided on the command line #31031

Open
pjweinb opened this Issue Mar 25, 2019 · 3 comments

Comments

Projects
None yet
3 participants
@pjweinb
Copy link
Contributor

pjweinb commented Mar 25, 2019

What version of Go are you using (go version)?

go version go1.12 linux/amd64

What operating system and processor architecture are you using (go env)?

linux

What did you do?

go build cmd/gopls

and it says
can't load package: package cmd/gopls: cannot find package "." in:
/usr/lib/google-golang/src/cmd/gopls

Note that . is not mentioned anywhere in the command, nor is there an "import ." anywhere either.

Of course,
go build ./cmd/gopls works,
but the other error message is not helpful.

@bcmills

This comment has been minimized.

Copy link
Member

bcmills commented Apr 12, 2019

Please complete the issue template.

In particular, we need the go env output to determine whether you are running in module mode or GOPATH mode, since the package-resolution logic differs between the two modes.

@bcmills bcmills changed the title go: build unhelpful error messge cmd/go: error message refers to "." instead of the path provided on the command line Apr 12, 2019

@bcmills

This comment has been minimized.

Copy link
Member

bcmills commented Apr 12, 2019

@jayconrod

This comment has been minimized.

Copy link
Contributor

jayconrod commented Apr 16, 2019

Reproduced in both modes in Go 1.12.4.

However, the error message is different at tip.

$ GO111MODULE=on go build cmd/gopls
can't load package: package cmd/gopls: unknown import path "cmd/gopls": cannot find module providing package cmd/gopls
$ GO111MODULE=off go build cmd/gopls
can't load package: package cmd/gopls: cannot find package "cmd/gopls" in any of:
	/Users/jayconrod/Code/go/src/cmd/gopls (from $GOROOT)
	/Users/jayconrod/go/src/cmd/gopls (from $GOPATH)

I think the GOPATH message is fine, but the module error message could be improved.

@jayconrod jayconrod added this to the Go1.13 milestone Apr 16, 2019

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.