golang/go

cmd/go: clarify error message when importing a package that could be (but isn't) in the main module

Open

#34,491 opened on Sep 24, 2019

View on GitHub
 (1 comment) (1 reaction) (0 assignees)Go (19,008 forks)batch import
GoCommandNeedsFixhelp wantedmodules

Repository metrics

Stars
 (133,883 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

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

Does this issue reproduce with the latest release?

Yes.

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

What did you do?

I imported a path that was not a valid package (because of a combination of build tags, test files, documentation package files, and/or no files present, but was a valid path to a directory on a filesystem (one which contained (an)other package(s)). go build ./... and go test ./... and go mod tidy report an error in finding the path to the package within the module.

What did you expect to see?

I guess it would have been nice to see (both) 2 things output (as @Helcaraxan and @thepudds have suggested in Gophers slack (#modules):

  1. There’s no such module online
  2. No *.go files matching current build constraints

What did you see instead?

Before the module was pushed to a GitHub repository (everything local)

https://gist.github.com/johnrichardrinehart/2d9944249e4d1e0f17c608149d50ff39

and after the module was pushed to a repository (github.com/johnrichardrinehart/a) instead of (github.com/a, as in the gist):

johnrinehart@modie test (master) $ go mod tidy
go: finding github.com/johnrichardrinehart/a/folder latest
github.com/johnrichardrinehart/a/folder/pkg imports
        github.com/johnrichardrinehart/a/folder: no matching versions for query "latest"

Contributor guide