Skip to content

Commit

Permalink
internal/gocommand: remove support for -workfile
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
findleyr committed Feb 18, 2022
1 parent e6a7e13 commit 897bd77
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 26 deletions.
14 changes: 0 additions & 14 deletions internal/gocommand/invoke.go
Expand Up @@ -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

Expand Down Expand Up @@ -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{}) {}
Expand All @@ -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)
Expand All @@ -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...)
}
Expand Down
13 changes: 1 addition & 12 deletions internal/lsp/cache/snapshot.go
Expand Up @@ -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)
Expand Down

0 comments on commit 897bd77

Please sign in to comment.