From 9c32af924b3d193718deb9d6fa9969fc9855eecd Mon Sep 17 00:00:00 2001 From: Rohan Challa Date: Fri, 21 Feb 2020 13:35:45 -0500 Subject: [PATCH] internal/lsp: create more descriptive temp go.mod name This change improves the temporary go.mod file name to include the base directory of the folder that is opened. Change-Id: Ide759222e268bdc24f82b29625ac18f4f285aa64 Reviewed-on: https://go-review.googlesource.com/c/tools/+/220361 Run-TryBot: Rohan Challa Reviewed-by: Robert Findley TryBot-Result: Gobot Gobot --- internal/lsp/cache/view.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/internal/lsp/cache/view.go b/internal/lsp/cache/view.go index 88489d58a6..82a94235e2 100644 --- a/internal/lsp/cache/view.go +++ b/internal/lsp/cache/view.go @@ -601,9 +601,10 @@ func (v *view) setBuildInformation(ctx context.Context, folder span.URI, env []s return nil } // Copy the current go.mod file into the temporary go.mod file. - // The file's name will be of the format go.1234.mod. - // It's temporary go.sum file should have the corresponding format of go.1234.sum. - tempModFile, err := ioutil.TempFile("", "go.*.mod") + // The file's name will be of the format go.directory.1234.mod. + // It's temporary go.sum file should have the corresponding format of go.directory.1234.sum. + tmpPattern := fmt.Sprintf("go.%s.*.mod", filepath.Base(folder.Filename())) + tempModFile, err := ioutil.TempFile("", tmpPattern) if err != nil { return err }