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()