Skip to content

Commit f4888c5

Browse files
committed
gopls/internal/settings: remove support for "allowModfileModifications"
That no tests fail when this setting is removed is evidence enough that it is unsupported. Additionally, this was one of the final pins holding together some of the unnecessary complexity of the gocommand package, which subsequent CLs will untangle. Fixes golang/go#65546 Change-Id: I8efececfd743d898c5f72c6a2d2a416e023ee3bc Reviewed-on: https://go-review.googlesource.com/c/tools/+/579435 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Alan Donovan <[email protected]>
1 parent d857e85 commit f4888c5

File tree

4 files changed

+5
-35
lines changed

4 files changed

+5
-35
lines changed

gopls/doc/settings.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,6 @@ gopls has to do to keep your workspace up to date.
108108

109109
Default: `true`.
110110

111-
#### **allowModfileModifications** *bool*
112-
113-
**This setting is experimental and may be deleted.**
114-
115-
allowModfileModifications disables -mod=readonly, allowing imports from
116-
out-of-scope modules. This option will eventually be removed.
117-
118-
Default: `false`.
119-
120111
#### **allowImplicitNetworkAccess** *bool*
121112

122113
**This setting is experimental and may be deleted.**

gopls/internal/cache/snapshot.go

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,6 @@ func (s *Snapshot) RunGoModUpdateCommands(ctx context.Context, wd string, run fu
502502
// TODO(adonovan): simplify cleanup mechanism. It's hard to see, but
503503
// it used only after call to tempModFile.
504504
func (s *Snapshot) goCommandInvocation(ctx context.Context, flags InvocationFlags, inv *gocommand.Invocation) (tmpURI protocol.DocumentURI, updatedInv *gocommand.Invocation, cleanup func(), err error) {
505-
allowModfileModificationOption := s.Options().AllowModfileModifications
506505
allowNetworkOption := s.Options().AllowImplicitNetworkAccess
507506

508507
// TODO(rfindley): it's not clear that this is doing the right thing.
@@ -555,17 +554,10 @@ func (s *Snapshot) goCommandInvocation(ctx context.Context, flags InvocationFlag
555554
// (As noted in various TODOs throughout this function, this is very
556555
// confusing and not obviously correct, but tests pass and we will eventually
557556
// rewrite this entire function.)
558-
if inv.ModFlag == "" {
559-
switch mode {
560-
case LoadWorkspace, Normal:
561-
if allowModfileModificationOption {
562-
inv.ModFlag = mutableModFlag
563-
}
564-
case WriteTemporaryModFile:
565-
inv.ModFlag = mutableModFlag
566-
// -mod must be readonly when using go.work files - see issue #48941
567-
inv.Env = append(inv.Env, "GOWORK=off")
568-
}
557+
if inv.ModFlag == "" && mode == WriteTemporaryModFile {
558+
inv.ModFlag = mutableModFlag
559+
// -mod must be readonly when using go.work files - see issue #48941
560+
inv.Env = append(inv.Env, "GOWORK=off")
569561
}
570562

571563
// TODO(rfindley): if inv.ModFlag was already set to "mod", we may not have

gopls/internal/settings/api_json.go

Lines changed: 0 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gopls/internal/settings/settings.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,6 @@ type BuildOptions struct {
123123
// gopls has to do to keep your workspace up to date.
124124
ExpandWorkspaceToModule bool `status:"experimental"`
125125

126-
// AllowModfileModifications disables -mod=readonly, allowing imports from
127-
// out-of-scope modules. This option will eventually be removed.
128-
AllowModfileModifications bool `status:"experimental"`
129-
130126
// AllowImplicitNetworkAccess disables GOPROXY=off, allowing implicit module
131127
// downloads rather than requiring user action. This option will eventually
132128
// be removed.
@@ -986,8 +982,7 @@ func (o *Options) set(name string, value interface{}, seen map[string]struct{})
986982
result.deprecated("")
987983

988984
case "allowModfileModifications":
989-
result.softErrorf("gopls setting \"allowModfileModifications\" is deprecated.\nPlease comment on https://go.dev/issue/65546 if this impacts your workflow.")
990-
result.setBool(&o.AllowModfileModifications)
985+
result.deprecated("")
991986

992987
case "allowImplicitNetworkAccess":
993988
result.setBool(&o.AllowImplicitNetworkAccess)

0 commit comments

Comments
 (0)