From 5774b907c37e7dfd04eaec80da49357f5b1ed8f2 Mon Sep 17 00:00:00 2001 From: Chang Liu Date: Mon, 29 Jul 2019 17:20:08 +0800 Subject: [PATCH] mod: wrong require when migrate from dep with source config This change modifies Go to generate correct go.mod file. Currently go-mod puts wrong module path in requires when Gopkg.toml contains source config. for example, there is a constraint declaration in Gopkg.toml as following: [[constraint]] name = "github.com/minio/minio-go" revision = "0415038e6086735b8c917d7fdb2ca93f07d7fb60" source = "https://github.com/liuchang0812/minio-go" go-mod puts `github.com/liuchang0812/minio-go` in requires. but, it should be `github.com/minio/minio-go` Signed-off-by: Chang Liu --- src/cmd/go/internal/modconv/convert.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cmd/go/internal/modconv/convert.go b/src/cmd/go/internal/modconv/convert.go index 558664a8b38616..d4ad07e8ca3a3b 100644 --- a/src/cmd/go/internal/modconv/convert.go +++ b/src/cmd/go/internal/modconv/convert.go @@ -91,8 +91,10 @@ func ConvertLegacyConfig(f *modfile.File, file string, data []byte) error { if err != nil { return fmt.Errorf("add replace: %v", err) } + f.AddNewRequire(re.Old.Path, need[path], false) + } else { + f.AddNewRequire(path, need[path], false) } - f.AddNewRequire(path, need[path], false) } f.Cleanup()