Navigation Menu

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: cannot import redirected/renamed packages #23974

Closed
jakebailey opened this issue Feb 21, 2018 · 2 comments
Closed

x/vgo: cannot import redirected/renamed packages #23974

jakebailey opened this issue Feb 21, 2018 · 2 comments
Milestone

Comments

@jakebailey
Copy link

jakebailey commented Feb 21, 2018

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

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

Does this issue reproduce with the latest release?

Yes? (Not sure how to answer this given it's x/vgo and all.)

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

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/jake/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/jake/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-build991479630=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Created an out-of-GOPATH directory, with a main.go with the following contents.

package main // import "github.com/jakebailey/dvgotest"

import (
	"context"
	"fmt"

	"github.com/docker/docker/client"
)

func main() {
	ctx := context.Background()

	cli, err := client.NewEnvClient()
	if err != nil {
		panic(err)
	}
	defer cli.Close()

	fmt.Println(cli.Ping(ctx))
}

Then, did a vgo build.

What did you expect to see?

A built binary, which logs the ping message to/from dockerd, say:

{1.36 linux false} <nil>

What did you see instead?

vgo: resolving import "github.com/docker/docker/client"
vgo: import "github.com/jakebailey/dvgotest" ->
	import "github.com/docker/docker/client": module path of repo is github.com/moby/moby, not github.com/docker/docker/client (moved)

Which is kind of correct, however the Docker source has maintained its github.com/docker/docker/* package names, even though the repos were moved to the moby account. However, github.com/docker/docker/* is the cannoical name for the imports. This has caused issues before, most recently golang/gddo#534.

Replacing the import path with the (technically incorrect) github.com/moby/moby/client nets this result:

vgo: resolving import "github.com/moby/moby/client"
findRepo: XML syntax error on line 13: expected attribute name in element
vgo: finding github.com/moby/moby (latest)
vgo: adding github.com/moby/moby v1.13.1
vgo: finding github.com/moby/moby v1.13.1
findRepo: XML syntax error on line 13: expected attribute name in element
vgo: finding github.com/moby/moby v1.13.1
findRepo: XML syntax error on line 13: expected attribute name in element
vgo: parsing downloaded go.mod: go.mod:21: invalid module: github.com/coreos/go-systemd should be v1, not v4 (v4.0.0)
go.mod:41: invalid module: github.com/godbus/dbus should be v1, not v4 (v4.0.0)
go.mod:81: invalid module: github.com/tchap/go-patricia should be v1, not v2 (v2.2.6)

Which (besides the XML syntax errors) confusingly refers to packages that the Docker client doesn't even import, but I found in moby.out and moby.vconf in golang.org/x/vgo/vendor/cmd/go/internal/modconv/testdata.

For reference, a minimal Gopkg.toml to make the Docker client work looks like:

[[constraint]]
  branch = "master"
  name = "github.com/docker/docker"

[[override]]
  branch = "master"
  name = "github.com/docker/distribution"

I wasn't expecting a complicated project like the Docker client to work with such an early demo, but I figured I report it so it's on the books. Happy vgo-ing.

@rsc
Copy link
Contributor

rsc commented Apr 2, 2018

Duplicate of #24102. Definitely needs a fix.

@rsc rsc closed this as completed Apr 2, 2018
@tv42
Copy link

tv42 commented May 25, 2018

For what it's worth, I just repeated this test with vgo 7c0cf33f39ccf5d8e4c59d34a150425ddac7df6a and apart from go.googlesource.com giving me a temporary internal error, it builds just fine.

Here's a slightly edited history of commands I ran on a fresh GCE vm running Debian 9.4 (default):

wget https://dl.google.com/go/go1.10.2.linux-amd64.tar.gz
mkdir src
cd src
tar xvzf ~/go1.10.2.linux-amd64.tar.gz 
cd
export PATH=$PATH:$PWD/src/go/bin
sudo apt-get install git build-essential
go get golang.org/x/vgo
export PATH=$PATH:$PWD/go/bin
mkdir z
cd z
cat >main.go
touch go.mod
vgo build -v
./dvgotest 

@golang golang locked and limited conversation to collaborators May 25, 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