cmd/go/internal/modfetch: fix legacy config file path parsed failed
The func ConvertLegacyConfig should be expected to pass in a / path.
Fixes golang/go#25110
Change-Id: Id092833bf14be667911341f2f2ca5cf97210febc
Reviewed-on: https://go-review.googlesource.com/110117
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
diff --git a/vendor/cmd/go/internal/modfetch/convert.go b/vendor/cmd/go/internal/modfetch/convert.go
index 1d7493d..5c482be 100644
--- a/vendor/cmd/go/internal/modfetch/convert.go
+++ b/vendor/cmd/go/internal/modfetch/convert.go
@@ -15,6 +15,8 @@
"cmd/go/internal/semver"
)
+// ConvertLegacyConfig converts legacy config to modfile.
+// The file argument is slash-delimited.
func ConvertLegacyConfig(f *modfile.File, file string, data []byte) error {
i := strings.LastIndex(file, "/")
j := -2
diff --git a/vendor/cmd/go/internal/vgo/init.go b/vendor/cmd/go/internal/vgo/init.go
index 0c595d1..7424297 100644
--- a/vendor/cmd/go/internal/vgo/init.go
+++ b/vendor/cmd/go/internal/vgo/init.go
@@ -181,6 +181,7 @@
return
}
fmt.Fprintf(os.Stderr, "vgo: copying requirements from %s\n", cfg)
+ cfg = filepath.ToSlash(cfg)
if err := modfetch.ConvertLegacyConfig(modFile, cfg, data); err != nil {
base.Fatalf("vgo: %v", err)
}
diff --git a/vendor/cmd/go/vgo_test.go b/vendor/cmd/go/vgo_test.go
index 70d1086..f97dbf5 100644
--- a/vendor/cmd/go/vgo_test.go
+++ b/vendor/cmd/go/vgo_test.go
@@ -177,3 +177,20 @@
tg.grepStderrNot("copying requirements from .*Gopkg.lock", "should not copy Gopkg.lock again")
}
+
+func TestConvertLegacyConfig(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/Gopkg.lock"), []byte(`
+ [[projects]]
+ name = "github.com/pkg/errors"
+ packages = ["."]
+ revision = "645ef00459ed84a119197bfb8d8205042c6df63d"
+ version = "v0.8.0"`), 0666))
+ tg.must(ioutil.WriteFile(tg.path("x/main.go"), []byte("package x // import \"x\"\n import _ \"github.com/pkg/errors\""), 0666))
+ tg.cd(tg.path("x"))
+ tg.run("-vgo", "build")
+}