From 7ae4988eb4d97c49ed0a632032fed8a8d41a2a3d Mon Sep 17 00:00:00 2001 From: Rob Findley Date: Mon, 27 Apr 2020 19:24:15 -0400 Subject: [PATCH] internal/lsp/fake: clean up Workspace.proxydir on close This change was unfortunately lost while rebasing, resulting in a lot of unremoved directories. Change-Id: Icc1b667e31ac85e617b1c3a8d7c58f78e999d151 Reviewed-on: https://go-review.googlesource.com/c/tools/+/230314 Run-TryBot: Robert Findley TryBot-Result: Gobot Gobot Reviewed-by: Rebecca Stambler --- internal/lsp/fake/workspace.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/internal/lsp/fake/workspace.go b/internal/lsp/fake/workspace.go index 0e93abe035..2742b64da3 100644 --- a/internal/lsp/fake/workspace.go +++ b/internal/lsp/fake/workspace.go @@ -308,7 +308,7 @@ func (w *Workspace) writeFileData(path string, content string) error { } func (w *Workspace) removeAll() error { - var wsErr, gopathErr error + var wsErr, gopathErr, proxyErr error if w.gopath != "" { if err := w.RunGoCommand(context.Background(), "clean", "-modcache"); err != nil { gopathErr = fmt.Errorf("cleaning modcache: %v", err) @@ -319,8 +319,11 @@ func (w *Workspace) removeAll() error { if w.workdir != "" { wsErr = os.RemoveAll(w.workdir) } - if wsErr != nil || gopathErr != nil { - return fmt.Errorf("error(s) cleaning workspace: removing workdir: %v; removing gopath: %v", wsErr, gopathErr) + if w.proxydir != "" { + proxyErr = os.RemoveAll(w.proxydir) + } + if wsErr != nil || gopathErr != nil || proxyErr != nil { + return fmt.Errorf("error(s) cleaning workspace: removing workdir: %v; removing gopath: %v; removing proxy: %v", wsErr, gopathErr, proxyErr) } return nil }