Skip to content

Commit 0d40b49

Browse files
committed
internal/gocommand: remove support for -workfile
Remove support for passing the -workfile flag now that the go command no longer supports it. Updates #51215 Change-Id: I95d73fb1a3a6d9bcfaaae5e22e44722118d12c03 Reviewed-on: https://go-review.googlesource.com/c/tools/+/386536 Trust: Robert Findley <[email protected]> Run-TryBot: Robert Findley <[email protected]> gopls-CI: kokoro <[email protected]> Reviewed-by: Hyang-Ah Hana Kim <[email protected]> TryBot-Result: Gopher Robot <[email protected]> (cherry picked from commit 897bd77) Reviewed-on: https://go-review.googlesource.com/c/tools/+/386537
1 parent fe6cc9a commit 0d40b49

File tree

2 files changed

+1
-26
lines changed

2 files changed

+1
-26
lines changed

internal/gocommand/invoke.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,6 @@ type Invocation struct {
139139
// If ModFile is set, the go command is invoked with -modfile=ModFile.
140140
ModFile string
141141

142-
// If WorkFile is set, the go command is invoked with -workfile=WorkFile.
143-
WorkFile string
144-
145142
// If Overlay is set, the go command is invoked with -overlay=Overlay.
146143
Overlay string
147144

@@ -170,9 +167,6 @@ func (i *Invocation) runWithFriendlyError(ctx context.Context, stdout, stderr io
170167
}
171168

172169
func (i *Invocation) run(ctx context.Context, stdout, stderr io.Writer) error {
173-
if i.ModFile != "" && i.WorkFile != "" {
174-
return fmt.Errorf("bug: go command invoked with both -modfile and -workfile")
175-
}
176170
log := i.Logf
177171
if log == nil {
178172
log = func(string, ...interface{}) {}
@@ -185,11 +179,6 @@ func (i *Invocation) run(ctx context.Context, stdout, stderr io.Writer) error {
185179
goArgs = append(goArgs, "-modfile="+i.ModFile)
186180
}
187181
}
188-
appendWorkFile := func() {
189-
if i.WorkFile != "" {
190-
goArgs = append(goArgs, "-workfile="+i.WorkFile)
191-
}
192-
}
193182
appendModFlag := func() {
194183
if i.ModFlag != "" {
195184
goArgs = append(goArgs, "-mod="+i.ModFlag)
@@ -208,19 +197,16 @@ func (i *Invocation) run(ctx context.Context, stdout, stderr io.Writer) error {
208197
// mod needs the sub-verb before flags.
209198
goArgs = append(goArgs, i.Args[0])
210199
appendModFile()
211-
appendWorkFile()
212200
goArgs = append(goArgs, i.Args[1:]...)
213201
case "get":
214202
goArgs = append(goArgs, i.BuildFlags...)
215203
appendModFile()
216-
appendWorkFile()
217204
goArgs = append(goArgs, i.Args...)
218205

219206
default: // notably list and build.
220207
goArgs = append(goArgs, i.BuildFlags...)
221208
appendModFile()
222209
appendModFlag()
223-
appendWorkFile()
224210
appendOverlayFlag()
225211
goArgs = append(goArgs, i.Args...)
226212
}

internal/lsp/cache/snapshot.go

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -425,18 +425,7 @@ func (s *snapshot) goCommandInvocation(ctx context.Context, flags source.Invocat
425425
// 3. We're using at least Go 1.18.
426426
useWorkFile := !needTempMod && s.workspace.moduleSource == goWorkWorkspace && s.view.goversion >= 18
427427
if useWorkFile {
428-
workURI := uriForSource(s.workspace.root, goWorkWorkspace)
429-
workFH, err := s.GetFile(ctx, workURI)
430-
if err != nil {
431-
return "", nil, cleanup, err
432-
}
433-
// TODO(rfindley): we should use the last workfile that actually parsed, as
434-
// tracked by the workspace.
435-
tmpURI, cleanup, err = tempWorkFile(workFH)
436-
if err != nil {
437-
return "", nil, cleanup, err
438-
}
439-
inv.WorkFile = tmpURI.Filename()
428+
// TODO(#51215): build a temp workfile and set GOWORK in the environment.
440429
} else if useTempMod {
441430
if modURI == "" {
442431
return "", nil, cleanup, fmt.Errorf("no go.mod file found in %s", inv.WorkingDir)

0 commit comments

Comments
 (0)