gopls/internal/settings: default "includeReplaceInWorkspace" to false

As described in golang/go#65762, treating locally replaced modules the
same as workspace modules doesn't really work, since there will be
missing go.sum entries. Fortunately, this functionality was guarded by
the "includeReplaceInWorkspace" setting. Revert the default value for
this setting.

Fixes golang/go#65762

Change-Id: I521acb2863404cba7612887aa7730075dcfebd96
Reviewed-on: https://go-review.googlesource.com/c/tools/+/564558
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
This commit is contained in:
Rob Findley 2024-02-16 21:26:22 +00:00 коммит произвёл Robert Findley
Родитель 68515eaff7
Коммит 3ac77cb1c1
2 изменённых файлов: 13 добавлений и 6 удалений

17
gopls/internal/cache/session_test.go поставляемый
Просмотреть файл

@ -20,6 +20,7 @@ import (
func TestZeroConfigAlgorithm(t *testing.T) {
testenv.NeedsExec(t) // executes the Go command
t.Setenv("GOPACKAGESDRIVER", "off")
type viewSummary struct {
// fields exported for cmp.Diff
@ -33,6 +34,12 @@ func TestZeroConfigAlgorithm(t *testing.T) {
options func(dir string) map[string]any // options may refer to the temp dir
}
includeReplaceInWorkspace := func(string) map[string]any {
return map[string]any{
"includeReplaceInWorkspace": true,
}
}
type test struct {
name string
files map[string]string // use a map rather than txtar as file content is tiny
@ -235,7 +242,7 @@ func TestZeroConfigAlgorithm(t *testing.T) {
"b/go.mod": "module golang.org/b\ngo 1.18\n",
"b/b.go": "package b",
},
[]folderSummary{{dir: "."}},
[]folderSummary{{dir: ".", options: includeReplaceInWorkspace}},
[]string{"a/a.go", "b/b.go"},
[]viewSummary{{GoModView, ".", nil}},
},
@ -247,7 +254,7 @@ func TestZeroConfigAlgorithm(t *testing.T) {
"b/go.mod": "module golang.org/b\ngo 1.18\nrequire golang.org/a v1.2.3\nreplace golang.org/a => ../",
"b/b.go": "package b",
},
[]folderSummary{{dir: "."}},
[]folderSummary{{dir: ".", options: includeReplaceInWorkspace}},
[]string{"a/a.go", "b/b.go"},
[]viewSummary{{GoModView, ".", nil}, {GoModView, "b", nil}},
},
@ -277,12 +284,12 @@ replace (
"d/go.mod": "module golang.org/d\ngo 1.18",
"d/d.go": "package d",
},
[]folderSummary{{dir: "."}},
[]folderSummary{{dir: ".", options: includeReplaceInWorkspace}},
[]string{"b/b.go", "c/c.go", "d/d.go"},
[]viewSummary{{GoModView, ".", nil}, {GoModView, "d", nil}},
},
{
"go.mod with many replace",
"go.mod with replace outside the workspace",
map[string]string{
"go.mod": "module golang.org/a\ngo 1.18",
"a.go": "package a",
@ -290,7 +297,7 @@ replace (
"b/b.go": "package b",
},
[]folderSummary{{dir: "b"}},
[]string{"a/a.go", "b/b.go"},
[]string{"a.go", "b/b.go"},
[]viewSummary{{GoModView, "b", nil}},
},
{

Просмотреть файл

@ -115,7 +115,7 @@ func DefaultOptions(overrides ...func(*Options)) *Options {
ReportAnalysisProgressAfter: 5 * time.Second,
TelemetryPrompt: false,
LinkifyShowMessage: false,
IncludeReplaceInWorkspace: true,
IncludeReplaceInWorkspace: false,
ZeroConfig: true,
},
Hooks: Hooks{