Description
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (go version
)?
28ae82663a1c57c185312b60a2eae8cf06cc24b4
which is on the release-branch.go1.10
branch, and includes https://go-review.googlesource.com/c/go/+/114500.
Does this issue reproduce with the latest release?
n/a
What operating system and processor architecture are you using (go env
)?
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/myitcv/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/tmp/tmp.xwRnLArihb"
GORACE=""
GOROOT="/home/myitcv/gos"
GOTMPDIR=""
GOTOOLDIR="/home/myitcv/gos/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-build189190539=/tmp/go-build -gno-record-gcc-switches"
What did you do?
Use the Go 1.10 backport branch, specifically:
$ cd /tmp
$ git clone -q https://github.com/golang/go
$ cd go/src
$ git checkout -q 28ae82663a1c57c185312b60a2eae8cf06cc24b4
$ ./make.bash
Building Go cmd/dist using /usr/local/go.
Building Go toolchain1 using /usr/local/go.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain1.
Building Go toolchain3 using go_bootstrap and Go toolchain2.
Building packages and commands for linux/amd64.
---
Installed Go for linux/amd64 in /tmp/go
Installed commands in /tmp/go/bin
$ export PATH=/tmp/go/bin:$PATH
$ which go
/tmp/go/bin/go
$ go version
go version go1.10.2 linux/amd64
Get vgo:
$ go get -u golang.org/x/vgo
Create a simple module that depends on v2 of a package, and build:
$ cd $(mktemp -d)
$ export GOPATH=$PWD
$ mkdir -p src/example.com/hello
$ cd src/example.com/hello
$ cat <<EOD >hello.go
package main // import "example.com/hello"
import (
"fmt"
"github.com/myitcv/vgo_example_compat/v2"
"github.com/myitcv/vgo_example_compat/v2/sub"
)
func main() {
fmt.Println(vgo_example_compat.X, sub.Y)
}
EOD
$ echo >go.mod
$ vgo build
vgo: resolving import "github.com/myitcv/vgo_example_compat/v2"
vgo: finding github.com/myitcv/vgo_example_compat/v2 (latest)
vgo: adding github.com/myitcv/vgo_example_compat/v2 v2.0.0
vgo: finding github.com/myitcv/vgo_example_compat/v2 v2.0.0
vgo: downloading github.com/myitcv/vgo_example_compat/v2 v2.0.0
$ ./hello
2 2
Now try to go get v2:
$ go get github.com/myitcv/vgo_example_compat/v2
package github.com/myitcv/vgo_example_compat/v2: cannot find package "github.com/myitcv/vgo_example_compat/v2" in any of:
/tmp/go/src/github.com/myitcv/vgo_example_compat/v2 (from $GOROOT)
/tmp/tmp.uBC7919n7v/src/github.com/myitcv/vgo_example_compat/v2 (from $GOPATH)
Note that this works (unsuprisingly):
$ go get github.com/myitcv/vgo_example_compat
Now try and build:
$ go build
$ ./hello
2 2
Now try and list v2 of the package on which we depend:
$ go list github.com/myitcv/vgo_example_compat/v2
can't load package: package github.com/myitcv/vgo_example_compat/v2: cannot find package "github.com/myitcv/vgo_example_compat/v2" in any of:
/tmp/go/src/github.com/myitcv/vgo_example_compat/v2 (from $GOROOT)
/tmp/tmp.uBC7919n7v/src/github.com/myitcv/vgo_example_compat/v2 (from $GOPATH)
Note that this works:
$ go list github.com/myitcv/vgo_example_compat
github.com/myitcv/vgo_example_compat
Now verify how go/build behaves with these imports paths:
$ cat <<EOD >run.go
// +build ignore
package main
import (
"fmt"
"os"
"go/build"
)
func main() {
bpkg, err := build.Import(os.Args[1], ".", 0)
if err != nil {
panic(err)
}
fmt.Printf("%v\n", bpkg.Dir)
}
EOD
Run for the v2 import path:
$ go run run.go github.com/myitcv/vgo_example_compat/v2
panic: cannot find package "github.com/myitcv/vgo_example_compat/v2" in any of:
/tmp/go/src/github.com/myitcv/vgo_example_compat/v2 (from $GOROOT)
/tmp/tmp.uBC7919n7v/src/github.com/myitcv/vgo_example_compat/v2 (from $GOPATH)
goroutine 1 [running]:
main.main()
/tmp/tmp.uBC7919n7v/src/example.com/hello/run.go:14 +0x10a
exit status 2
Note that this works:
$ go run run.go github.com/myitcv/vgo_example_compat
/tmp/tmp.uBC7919n7v/src/github.com/myitcv/vgo_example_compat
What did you expect to see?
I'm unclear whether we should/would expect go list
etc to work with the backported changes for */v2/*
import paths?
Also I note that go/build
could/should have these resolution powers too?
What did you see instead?
The Go 1.10 backported changes not working for go list
or via use of go/build
for */v2/*
import paths.
/cc @rsc