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: can't use submodules along with "parent" modules #26250

mwf opened this issue Jul 6, 2018 · 5 comments


Copy link

commented Jul 6, 2018

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

go version go1.10.3 darwin/amd64 vgo:2018-02-20.1

Latest vgo:

commit 6cd5a417451d8ee907692eded07ef1b6b53825b1 (HEAD -> master, origin/master, origin/HEAD)
Author: Bryan C. Mills <>
Date:   Mon Jul 2 16:43:34 2018 -0400

    cmd/go/internal/modcmd: use the correct path in verifyMod

What did you do?

Please refer to

I'm very sorry, but this case doesn't have standalone example, because tagging revisions and active repo usage is involved.

Let's assume we are in active development phase with versions v0.x.

At some point we decide to move some package to a standalone module, to split the dependencies and to have better semantic structure.

Thus cmd package is introduced to a separate module

But it turns out you can't use both and at the same time. Have a look at example project.

What did you expect to see?

vgo get should run without error and get the latest v0.0.1

What did you see instead?

$ cd ./example && vgo get
vgo: import "": found in both v0.0.2 and v0.0.1

The actual error is absolutely strange to me. Because formally v0.0.2 doesn't contain cmd package:

vgo mod -packages

This is a case not only for a refactoring (like introducing new modules for existing packages), but also if you make a brand-new submodule and try to use both "parent" and the new one. The error is the same.

@gopherbot gopherbot added this to the vgo milestone Jul 6, 2018


This comment has been minimized.

Copy link

commented Jul 6, 2018

And the second connected issue - vgo install can't work with "submodules"

vgo install
vgo: import "" [/Users/ikorolev/.gvm/pkgsets/go1.10.3/global/src/mod/]: open /Users/ikorolev/.gvm/pkgsets/go1.10.3/global/src/mod/ no such file or directory

It assumes cmd is in instead of standalone module.


This comment has been minimized.

Copy link

commented Jul 9, 2018

cc @myitcv
Have you tried working with nested modules? Because as I see in the #25855 discussion, there must be a way to use them.
Maybe I'm missing something essential.

cd `mktemp -d`
cat <<EOD > go.mod

require ( v0.0.3 v0.0.1
cat << EOD > main.go
package main

import (


func main() {
	fmt.Printf("vgo-modules version: %s\n", vgo_modules.Version)
	fmt.Printf("another_module.Foo: %s\n", another_module.Foo)
vgo run main.go
vgo: import "": found in both v0.0.3 and v0.0.1

This comment has been minimized.

Copy link

commented Jul 10, 2018

Change mentions this issue: cmd/go/internal/modload: finish Import implementation


This comment has been minimized.

Copy link

commented Jul 13, 2018

@mwf sorry, I missed you pinging me in this.

Yes, I have successfully worked with submodules. Here's a simple example

Given vgo has "become" go (as well as a whole load of other fixes landing), please can you try with Go tip?

Initialise a directory as a git repo, and add an appropriate remote:

$ mkdir go-modules-by-example-submodules
$ cd go-modules-by-example-submodules
$ git init
Initialized empty Git repository in /root/go-modules-by-example-submodules/.git/
$ git remote add origin$GITHUB_USERNAME/go-modules-by-example-submodules

Now define our root module, at the root of the repo, commit and push:

$ cat <<EOD >go.mod
$ git add go.mod
$ git commit -am 'Initial commit'
[master (root-commit) b143fe5] Initial commit
 1 file changed, 1 insertion(+)
 create mode 100644 go.mod
$ git push
 * [new branch]      master -> master

Now create a package b and test that it builds:

$ mkdir b
$ cd b
$ cat <<EOD >b.go
package b // import "$GITHUB_USERNAME/go-modules-by-example-submodules/b"

const Name = "Gopher"
$ echo >go.mod
$ go test
?	[no test files]

Now commit, tag and push our new package:

$ cd ..
$ git add b
$ git commit -am 'Add package b'
[master 4179a82] Add package b
 2 files changed, 4 insertions(+)
 create mode 100644 b/b.go
 create mode 100644 b/go.mod
$ git push
   b143fe5..4179a82  master -> master
$ git tag b/v0.1.1
$ git push origin b/v0.1.1
 * [new tag]         b/v0.1.1 -> b/v0.1.1

Now create a main package that will use b:

$ mkdir a
$ cd a
$ cat <<EOD >.gitignore
$ cat <<EOD >a.go
package main // import "$GITHUB_USERNAME/go-modules-by-example-submodules/a"

import (

const Name = b.Name

func main() {
$ echo >go.mod

Now let's build and run our package:

$ go build
go: finding v0.1.1
go: downloading v0.1.1
$ ./a
$ cat go.mod

require v0.1.1

See how we resolve to the tagged version of package b.

Finally we commit, tag and push our main package:

$ cd ..
$ git add a
$ git commit -am 'Add package a'
[master 6f5eb7d] Add package a
 4 files changed, 18 insertions(+)
 create mode 100644 a/.gitignore
 create mode 100644 a/a.go
 create mode 100644 a/go.mod
 create mode 100644 a/go.sum
$ git push
   4179a82..6f5eb7d  master -> master
$ git tag a/v1.0.0
$ git push origin a/v1.0.0
 * [new tag]         a/v1.0.0 -> a/v1.0.0

Version details

go version devel +8a330454dc Fri Jul 13 03:53:00 2018 +0000 linux/amd64

This comment has been minimized.

Copy link

commented Jul 17, 2018

Thanks for the answer, @myitcv ! fixed all this stuff, so it works with latest vgo and I believe it works in go tip :)

@golang golang locked and limited conversation to collaborators Jul 17, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
3 participants
You can’t perform that action at this time.