cmd/go/internal/vgo: add missing "none" to mvsReqs.Required
The next version is "none" when no newer version.
Change-Id: I5f658b23a47beed74d35afbe0fbde81bdb8ded2f
Reviewed-on: https://go-review.googlesource.com/118559
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
diff --git a/vendor/cmd/go/internal/vgo/load.go b/vendor/cmd/go/internal/vgo/load.go
index 28fbab3..ad5c6b8 100644
--- a/vendor/cmd/go/internal/vgo/load.go
+++ b/vendor/cmd/go/internal/vgo/load.go
@@ -433,7 +433,7 @@
if err != nil {
return cached{nil, err}
}
- if mv1.Version == "" {
+ if mv1.Version == "none" {
return cached{nil, fmt.Errorf("%s(%s) depends on excluded %s(%s) with no newer version available", mod.Path, mod.Version, mv.Path, mv.Version)}
}
mv = mv1
diff --git a/vendor/cmd/go/vgo_test.go b/vendor/cmd/go/vgo_test.go
index ce16d29..e13c7df 100644
--- a/vendor/cmd/go/vgo_test.go
+++ b/vendor/cmd/go/vgo_test.go
@@ -565,6 +565,42 @@
tg.grepStderr("github.com/gorilla/mux@v1.6.0 excluded", "print version excluded")
}
+func TestRequireExcluded(t *testing.T) {
+ tg := testgo(t)
+ defer tg.cleanup()
+ tg.makeTempdir()
+
+ tg.must(os.MkdirAll(tg.path("x"), 0777))
+ tg.must(ioutil.WriteFile(tg.path("x/x.go"), []byte(`package x; import _ "github.com/gorilla/mux"`), 0666))
+
+ tg.setenv(homeEnvName(), tg.path("home"))
+ tg.cd(tg.path("x"))
+
+ tg.must(ioutil.WriteFile(tg.path("x/go.mod"), []byte(`
+ module x
+ exclude github.com/gorilla/mux latest
+ require github.com/gorilla/mux latest
+ `), 0666))
+ tg.runFail("-vgo", "build")
+ tg.grepStderr("no newer version available", "only available version excluded")
+
+ tg.must(ioutil.WriteFile(tg.path("x/go.mod"), []byte(`
+ module x
+ exclude github.com/gorilla/mux v1.6.1
+ require github.com/gorilla/mux v1.6.1
+ `), 0666))
+ tg.run("-vgo", "build")
+ tg.grepStderr("finding github.com/gorilla/mux v1.6.2", "find version 1.6.2")
+
+ tg.must(ioutil.WriteFile(tg.path("x/go.mod"), []byte(`
+ module x
+ exclude github.com/gorilla/mux v1.6.2
+ require github.com/gorilla/mux v1.6.1
+ `), 0666))
+ tg.run("-vgo", "build")
+ tg.grepStderr("finding github.com/gorilla/mux v1.6.1", "find version 1.6.1")
+}
+
func TestConvertLegacyConfig(t *testing.T) {
testenv.MustHaveExternalNetwork(t)
tg := testgo(t)