Skip to content

Commit 3ac77cb

Browse files
committed
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 <[email protected]> Reviewed-by: Alan Donovan <[email protected]>
1 parent 68515ea commit 3ac77cb

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

gopls/internal/cache/session_test.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020

2121
func TestZeroConfigAlgorithm(t *testing.T) {
2222
testenv.NeedsExec(t) // executes the Go command
23+
t.Setenv("GOPACKAGESDRIVER", "off")
2324

2425
type viewSummary struct {
2526
// fields exported for cmp.Diff
@@ -33,6 +34,12 @@ func TestZeroConfigAlgorithm(t *testing.T) {
3334
options func(dir string) map[string]any // options may refer to the temp dir
3435
}
3536

37+
includeReplaceInWorkspace := func(string) map[string]any {
38+
return map[string]any{
39+
"includeReplaceInWorkspace": true,
40+
}
41+
}
42+
3643
type test struct {
3744
name string
3845
files map[string]string // use a map rather than txtar as file content is tiny
@@ -235,7 +242,7 @@ func TestZeroConfigAlgorithm(t *testing.T) {
235242
"b/go.mod": "module golang.org/b\ngo 1.18\n",
236243
"b/b.go": "package b",
237244
},
238-
[]folderSummary{{dir: "."}},
245+
[]folderSummary{{dir: ".", options: includeReplaceInWorkspace}},
239246
[]string{"a/a.go", "b/b.go"},
240247
[]viewSummary{{GoModView, ".", nil}},
241248
},
@@ -247,7 +254,7 @@ func TestZeroConfigAlgorithm(t *testing.T) {
247254
"b/go.mod": "module golang.org/b\ngo 1.18\nrequire golang.org/a v1.2.3\nreplace golang.org/a => ../",
248255
"b/b.go": "package b",
249256
},
250-
[]folderSummary{{dir: "."}},
257+
[]folderSummary{{dir: ".", options: includeReplaceInWorkspace}},
251258
[]string{"a/a.go", "b/b.go"},
252259
[]viewSummary{{GoModView, ".", nil}, {GoModView, "b", nil}},
253260
},
@@ -277,20 +284,20 @@ replace (
277284
"d/go.mod": "module golang.org/d\ngo 1.18",
278285
"d/d.go": "package d",
279286
},
280-
[]folderSummary{{dir: "."}},
287+
[]folderSummary{{dir: ".", options: includeReplaceInWorkspace}},
281288
[]string{"b/b.go", "c/c.go", "d/d.go"},
282289
[]viewSummary{{GoModView, ".", nil}, {GoModView, "d", nil}},
283290
},
284291
{
285-
"go.mod with many replace",
292+
"go.mod with replace outside the workspace",
286293
map[string]string{
287294
"go.mod": "module golang.org/a\ngo 1.18",
288295
"a.go": "package a",
289296
"b/go.mod": "module golang.org/b\ngo 1.18\nrequire golang.org/a v1.2.3\nreplace golang.org/a => ../",
290297
"b/b.go": "package b",
291298
},
292299
[]folderSummary{{dir: "b"}},
293-
[]string{"a/a.go", "b/b.go"},
300+
[]string{"a.go", "b/b.go"},
294301
[]viewSummary{{GoModView, "b", nil}},
295302
},
296303
{

gopls/internal/settings/default.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ func DefaultOptions(overrides ...func(*Options)) *Options {
115115
ReportAnalysisProgressAfter: 5 * time.Second,
116116
TelemetryPrompt: false,
117117
LinkifyShowMessage: false,
118-
IncludeReplaceInWorkspace: true,
118+
IncludeReplaceInWorkspace: false,
119119
ZeroConfig: true,
120120
},
121121
Hooks: Hooks{

0 commit comments

Comments
 (0)