From 897bd77cd7177f6d679eafa9767ff6ef9211458a Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Fri, 18 Feb 2022 09:35:21 -0500 Subject: [PATCH] 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 Run-TryBot: Robert Findley gopls-CI: kokoro Reviewed-by: Hyang-Ah Hana Kim TryBot-Result: Gopher Robot --- internal/gocommand/invoke.go | 14 -------------- internal/lsp/cache/snapshot.go | 13 +------------ 2 files changed, 1 insertion(+), 26 deletions(-) diff --git a/internal/gocommand/invoke.go b/internal/gocommand/invoke.go index 64fbad3765..f753368346 100644 --- a/internal/gocommand/invoke.go +++ b/internal/gocommand/invoke.go @@ -139,9 +139,6 @@ type Invocation struct { // 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) runWithFriendlyError(ctx context.Context, stdout, stderr io } 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 @@ func (i *Invocation) run(ctx context.Context, stdout, stderr io.Writer) error { 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 @@ func (i *Invocation) run(ctx context.Context, stdout, stderr io.Writer) error { // 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 f3ca77212e..b9cd36c745 100644 --- a/internal/lsp/cache/snapshot.go +++ b/internal/lsp/cache/snapshot.go @@ -425,18 +425,7 @@ func (s *snapshot) goCommandInvocation(ctx context.Context, flags source.Invocat // 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)