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 <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
(cherry picked from commit 897bd77cd7177f6d679eafa9767ff6ef9211458a)
Reviewed-on: https://go-review.googlesource.com/c/tools/+/386537
diff --git a/internal/gocommand/invoke.go b/internal/gocommand/invoke.go
index 64fbad3..f753368 100644
--- a/internal/gocommand/invoke.go
+++ b/internal/gocommand/invoke.go
@@ -139,9 +139,6 @@
 	// If ModFile is set, the go command is invoked with -modfile=ModFile.
 	ModFile string
 
-	// If WorkFile is set, the go command is invoked with -workfile=WorkFile.
-	WorkFile string
-
 	// If Overlay is set, the go command is invoked with -overlay=Overlay.
 	Overlay string
 
@@ -170,9 +167,6 @@
 }
 
 func (i *Invocation) run(ctx context.Context, stdout, stderr io.Writer) error {
-	if i.ModFile != "" && i.WorkFile != "" {
-		return fmt.Errorf("bug: go command invoked with both -modfile and -workfile")
-	}
 	log := i.Logf
 	if log == nil {
 		log = func(string, ...interface{}) {}
@@ -185,11 +179,6 @@
 			goArgs = append(goArgs, "-modfile="+i.ModFile)
 		}
 	}
-	appendWorkFile := func() {
-		if i.WorkFile != "" {
-			goArgs = append(goArgs, "-workfile="+i.WorkFile)
-		}
-	}
 	appendModFlag := func() {
 		if i.ModFlag != "" {
 			goArgs = append(goArgs, "-mod="+i.ModFlag)
@@ -208,19 +197,16 @@
 		// mod needs the sub-verb before flags.
 		goArgs = append(goArgs, i.Args[0])
 		appendModFile()
-		appendWorkFile()
 		goArgs = append(goArgs, i.Args[1:]...)
 	case "get":
 		goArgs = append(goArgs, i.BuildFlags...)
 		appendModFile()
-		appendWorkFile()
 		goArgs = append(goArgs, i.Args...)
 
 	default: // notably list and build.
 		goArgs = append(goArgs, i.BuildFlags...)
 		appendModFile()
 		appendModFlag()
-		appendWorkFile()
 		appendOverlayFlag()
 		goArgs = append(goArgs, i.Args...)
 	}
diff --git a/internal/lsp/cache/snapshot.go b/internal/lsp/cache/snapshot.go
index f3ca772..b9cd36c 100644
--- a/internal/lsp/cache/snapshot.go
+++ b/internal/lsp/cache/snapshot.go
@@ -425,18 +425,7 @@
 	//  3. We're using at least Go 1.18.
 	useWorkFile := !needTempMod && s.workspace.moduleSource == goWorkWorkspace && s.view.goversion >= 18
 	if useWorkFile {
-		workURI := uriForSource(s.workspace.root, goWorkWorkspace)
-		workFH, err := s.GetFile(ctx, workURI)
-		if err != nil {
-			return "", nil, cleanup, err
-		}
-		// TODO(rfindley): we should use the last workfile that actually parsed, as
-		// tracked by the workspace.
-		tmpURI, cleanup, err = tempWorkFile(workFH)
-		if err != nil {
-			return "", nil, cleanup, err
-		}
-		inv.WorkFile = tmpURI.Filename()
+		// TODO(#51215): build a temp workfile and set GOWORK in the environment.
 	} else if useTempMod {
 		if modURI == "" {
 			return "", nil, cleanup, fmt.Errorf("no go.mod file found in %s", inv.WorkingDir)