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/compile: confusing message when go.mod file and vendor folder both present #44149

Closed
dotaheor opened this issue Feb 7, 2021 · 6 comments
Closed

Comments

@dotaheor
Copy link

@dotaheor dotaheor commented Feb 7, 2021

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

$ go version
go version go1.15.8 linux/amd64
go version go1.16rc1 linux/amd64

What did you do?

package main

import _ "aaa"

func main() {
}

What did you expect to see?

package aaa is not in GOROOT (GOROOT/src/aaa)

What did you see instead?

cannot find package "." in:
	ProjectRoot/vendor/aaa
@seankhliao
Copy link
Contributor

@seankhliao seankhliao commented Feb 7, 2021

What exactly did you do, I can't reproduce the issue as described

Also note that names without a dot in the first element are considered reserved for the standard library, using a proper name gives a better error message

» mkdir /tmp/example && cd /tmp/example

» go mod init example.com/foo
go: creating new go.mod: module example.com/foo

» cat << EOF > main.go
package main
import _ "aaa"
func main() {}
EOF

» go build
main.go:3:8: package aaa is not in GOROOT (/home/arccy/sdk/gotip/src/aaa)

» mkdir vendor

» go build
main.go:3:8: cannot find package "." in:
	/tmp/example/vendor/aaa

Loading

@dotaheor
Copy link
Author

@dotaheor dotaheor commented Feb 8, 2021

You exactly reproduced the error described above.

Loading

@seankhliao
Copy link
Contributor

@seankhliao seankhliao commented Feb 8, 2021

I don't think it's a problem? Without vendor/ a package with a name like aaa cannot be retrieved by standard tooling so it makes sense to report it as not found in GOROOT. With vendor/, which can be created by other tools, it is possible to use a package named like that

Loading

@dotaheor
Copy link
Author

@dotaheor dotaheor commented Feb 8, 2021

OK, but shouldn't the message be

cannot find package "aaa" in:
	ProjectRoot/vendor

package "." confuses people.

Loading

@seankhliao
Copy link
Contributor

@seankhliao seankhliao commented Feb 8, 2021

that's #38748

Loading

@dotaheor
Copy link
Author

@dotaheor dotaheor commented Feb 8, 2021

Looks so. Close it for that.

Loading

@dotaheor dotaheor closed this Feb 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants