Skip to content

Commit

Permalink
cmd/go: skip vgo.Init for the version subcommand
Browse files Browse the repository at this point in the history
Fixes golang/go#25903.

Change-Id: Ib3bcb90147cf5b452f41850aba733144e22c06f3
Reviewed-on: https://go-review.googlesource.com/119275
Reviewed-by: Russ Cox <[email protected]>
  • Loading branch information
Bryan C. Mills committed Jun 19, 2018
1 parent 5e60d5e commit f574d31
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions vendor/cmd/go/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ func Main() {
case "mod":
// Skip vgo.Init (which may insist on go.mod existing)
// so that go mod -init has a chance to write the file.
case "version":
// Skip vgo.Init so that users can report bugs against
// go mod -init.
case "vendor":
fmt.Fprintf(os.Stderr, "go vendor is now go mod -vendor\n")
os.Exit(2)
Expand Down
9 changes: 9 additions & 0 deletions vendor/cmd/go/vgo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -624,3 +624,12 @@ func TestVendorWithoutDeps(t *testing.T) {
tg.run("-vgo", "mod", "-vendor")
tg.grepStderr("vgo: no dependencies to vendor", "print vendor info")
}

func TestVersionWithoutModule(t *testing.T) {
tg := testgo(t)
defer tg.cleanup()
tg.makeTempdir()

tg.cd(tg.path("."))
tg.run("-vgo", "version")
}

0 comments on commit f574d31

Please sign in to comment.