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: clarify error message when importing a package that could be (but isn't) in the main module #34491

Open
johnrichardrinehart opened this issue Sep 24, 2019 · 1 comment

Comments

@johnrichardrinehart
Copy link

commented Sep 24, 2019

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

$ go version
go version go1.13 darwin/amd64

Does this issue reproduce with the latest release?

Yes.

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

go env
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/johnrinehart/Library/Caches/go-build"
GOENV="/Users/johnrinehart/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/johnrinehart/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/johnrinehart/MyGo/playground/test/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/wg/8x33rs4j5d7bgr5z58_4ql0m0000gn/T/go-build825724138=/tmp/go-build -gno-record-gcc-switches -fno-common"

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"
@bcmills bcmills changed the title Output details for importing a non-package path cmd/go: clarify error message when importing a package that could be (but isn't) in the main module Sep 24, 2019
@bcmills bcmills added the NeedsFix label Sep 24, 2019
@bcmills bcmills added this to the Go1.14 milestone Sep 24, 2019
@bcmills

This comment has been minimized.

Copy link
Member

commented Sep 24, 2019

Comparable error messages are here and here.

Implementation-wise, this should probably be encoded as a special case of PackageNotInModuleError for Mod == Target, with a corresponding special case in its Error method.

CC @jayconrod

@rsc rsc modified the milestones: Go1.14, Backlog Oct 9, 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.