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: better diagnostics for package missing in latest version #27102

Open
icholy opened this Issue Aug 20, 2018 · 6 comments

Comments

Projects
None yet
6 participants
@icholy

icholy commented Aug 20, 2018

Related Issue: prometheus/client_golang#442

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

go version go1.11rc1 linux/amd64

Does this issue reproduce with the latest release?

yes

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

GOARCH="amd64"
GOBIN="/home/icholy/Code/bin"
GOCACHE="/home/icholy/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/icholy/Code"
GOPROXY=""
GORACE=""
GOROOT="/home/icholy/sdk/go1.11rc1"
GOTMPDIR=""
GOTOOLDIR="/home/icholy/sdk/go1.11rc1/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build529551486=/tmp/go-build -gno-record-gcc-switches"

What did you do?

git clone https://github.com/icholy/prom_thing.git
cd prom_thing
go1.11rc1 build

What did you expect to see?

Success

What did you see instead?

go: finding github.com/prometheus/client_golang/api/prometheus latest
go: finding github.com/prometheus/client_golang/api latest
build prom_thing: cannot find module for path github.com/prometheus/client_golang/api/prometheus/v1
@VojtechVitek

This comment has been minimized.

VojtechVitek commented Aug 20, 2018

github.com/prometheus/client_golang/api/prometheus is not a module, it's a package

I think you need to change

-    github.com/prometheus/client_golang/api/prometheus/v1
+    github.com/prometheus/client_golang/api

in your import statement.

@icholy

This comment has been minimized.

icholy commented Aug 20, 2018

@VojtechVitek that just imports a different package which I don't need.

@rsc

This comment has been minimized.

Contributor

rsc commented Aug 21, 2018

The problem is that github.com/prometheus/client_golang/api/prometheus/v1 does not exist in the latest tagged commit of github.com/prometheus/client_golang, which is v0.8.0 and is quite old.

To get the latest commit on the master branch instead of the latest tagged commit, run:

go get github.com/prometheus/client_golang@master

Then your build will work. And maybe encourage the owners of github.com/prometheus/client_golang to tag v0.9.0.

@rsc rsc changed the title from cmd/go: cannot import package who's name is v1 to cmd/go: better diagnostics for package missing in latest version Aug 21, 2018

@rsc

This comment has been minimized.

Contributor

rsc commented Aug 21, 2018

Leaving this issue open to track emitting a clearer error message in this case. I'd like to see something along the lines of "github.com/prometheus/client_golang v0.8.0 has no package github.com/prometheus/client_golang/api/prometheus"

@rsc rsc added this to the Go1.12 milestone Aug 21, 2018

@rsc rsc added the modules label Aug 21, 2018

@krasi-georgiev

This comment has been minimized.

krasi-georgiev commented Aug 22, 2018

after a short discussion something like v0.9.0-pre.2 would be best for consistency with the other tags in the repo.

Would vgo understand this?

@bcmills bcmills modified the milestones: Go1.12, Go1.13 Oct 25, 2018

@rsc rsc self-assigned this Oct 25, 2018

@rsc rsc modified the milestones: Go1.13, Go1.12 Oct 25, 2018

@bcmills bcmills modified the milestones: Go1.12, Go1.13 Nov 16, 2018

@gopherbot

This comment has been minimized.

gopherbot commented Dec 10, 2018

Change https://golang.org/cl/153459 mentions this issue: cmd/go: fix 'go test' and 'go fmt' with files outside a module

gopherbot pushed a commit that referenced this issue Dec 11, 2018

cmd/go: fix 'go test' and 'go fmt' with files outside a module
Use the actual loader result in findModule instead of making
assumptions about nesting in the build list.
As a side-effect, this produces much clearer error messages for
packages that (for one reason or another) failed to load.

Adjust the package and module path outside a module to
"command-line-arguments". That string already appears in the output of
a number of (module-mode and GOPATH-mode) commands for file arguments,
and as far as I can tell operation outside a module is currently the
only case in which the module path of a package is not actually a
prefix of the import path.

Fixes #28011
Fixes #27099
Fixes #28943
Updates #27102
Updates #28459
Updates #27063

Change-Id: I61d5556df7b1b7d1efdaffa892f0e3e95b612d87
Reviewed-on: https://go-review.googlesource.com/c/153459
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>

@bcmills bcmills modified the milestones: Go1.13, Go1.12 Dec 12, 2018

@bcmills bcmills assigned bcmills and unassigned rsc Dec 12, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment