internal/lsp: build output to package during gc_details code lens
The gc annotation details code lens did build binaries during
diagnostics to the module root. When trying to enable details for a
main package in a sub directory, it failed since the output binary name
conflicted with the sub directory name.
Instead, specify output to the package directory during build to avoid
conflicts.
Change-Id: Idc11e0c6a9ba15a66645aeef89bffb5abde76928
Reviewed-on: https://go-review.googlesource.com/c/tools/+/246419
Run-TryBot: Pontus Leitzler <leitzler@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Peter Weinberger <pjw@google.com>
diff --git a/internal/lsp/source/gc_annotations.go b/internal/lsp/source/gc_annotations.go
index 9a80325..82ad2bc 100644
--- a/internal/lsp/source/gc_annotations.go
+++ b/internal/lsp/source/gc_annotations.go
@@ -23,7 +23,10 @@
if err := os.MkdirAll(outDir, 0700); err != nil {
return nil, err
}
- args := []string{fmt.Sprintf("-gcflags=-json=0,%s", outDir), pkgDir.Filename()}
+ args := []string{fmt.Sprintf("-gcflags=-json=0,%s", outDir),
+ fmt.Sprintf("-o=%s", pkgDir.Filename()),
+ pkgDir.Filename(),
+ }
err := snapshot.RunGoCommandDirect(ctx, "build", args)
if err != nil {
return nil, err