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

x/vgo: import path is resolved to the wrong version #25007

Closed
utrack opened this issue Apr 23, 2018 · 3 comments
Closed

x/vgo: import path is resolved to the wrong version #25007

utrack opened this issue Apr 23, 2018 · 3 comments
Milestone

Comments

@utrack
Copy link

utrack commented Apr 23, 2018

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

» vgo version
go version go1.10.1 linux/amd64 vgo:2018-02-20.1

Does this issue reproduce with the latest release?

Yes.

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

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/u/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/u/go"
GORACE=""
GOROOT="/usr/lib/go"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
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-build277438090=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I've imported a package using versioned syntax: import _ "github.com/gomodule/redigo/v2/redis"

What did you expect to see?

Version 2.0.0 of redigo imported;

» vgo list -t github.com/gomodule/redigo/v2                2018-04-23 12:55:36
github.com/gomodule/redigo/v2
        v2.0.0

What did you see instead?

Path is resolved to version 1.6 with v2 subdir -

CGO_ENABLED=0 CC=gcc vgo build -a -tags netgo -o /home/u/gtl/bx/listing_api/bin/listing_api ./cmd/listing_api
vgo: resolving import "github.com/gomodule/redigo/v2/redis"
vgo: finding github.com/gomodule/redigo (latest)
vgo: adding github.com/gomodule/redigo v1.6.0
vgo: import "myrepo/listing_api/cmd/listing_api" ->
        import "github.com/gomodule/redigo/v2/redis" [/home/u/go/src/v/github.com/gomodule/redigo@v1.6.0/v2/redis]: open /home/u/go/src/v/github.com/gomodule/redigo@v1.6.0/v2/redis: no such file or directory
make: *** [Makefile:10: build] Error 1
@gopherbot gopherbot added this to the vgo milestone Apr 23, 2018
@utrack utrack changed the title x/vgo: import path does not resolve to the required version x/vgo: import path is resolved to the wrong version Apr 23, 2018
@AlexRouSg
Copy link
Contributor

Import path with a /v2/ is only available for packages directly supporting vgo and has a go.mod file, redigo does not.

In addition to that, #24585 is about vgo incorrectly generating the go.mod file for legacy packages with versions >= v2.0.0

@FZambia
Copy link

FZambia commented May 6, 2018

At moment (with patch from #24585) with code that imports github.com/gomodule/redigo/redis:

package hello // import "github.com/FZambia/hello"

import (
	"fmt"

	"github.com/gomodule/redigo/redis"
)

func DoSomething() {
	fmt.Println(redis.ErrPoolExhausted)
}

When running vgo build with empty go.mod file I get an output:

fz@hello: vgo build
vgo: resolving import "github.com/gomodule/redigo/redis"
vgo: finding github.com/gomodule/redigo (latest)
vgo: adding github.com/gomodule/redigo v1.6.0
vgo: resolving import "github.com/garyburd/redigo/internal"
vgo: finding github.com/garyburd/redigo (latest)
vgo: adding github.com/garyburd/redigo v1.6.0
../v/github.com/gomodule/redigo@v1.6.0/redis/pool.go:28:2: use of internal package not allowed

So it still resolves to v1.6.0 and not allowing to work with latest redigo version. Is this expected and to work with v2 go.mod must be introduced in redigo?

@rsc
Copy link
Contributor

rsc commented Jun 6, 2018

Yes, if github.com/gomodule/redigo does not opt into semantic import versioning by creating a go.mod that says 'module github.com/gomodule/redigo/v2', then you cannot import it using that path.

However, you can still import the old name under a pseudo-version. If you run

vgo get github.com/gomodule/redigo@v2.0.0

then vgo will add to go.mod not v2.0.0 (that doesn't match the module path) but instead

github.com/gomodule/redigo v0.0.0-20180314223443-9c11da706d9b

which is the same code.

@rsc rsc closed this as completed Jun 6, 2018
@golang golang locked and limited conversation to collaborators Jun 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants