1
0
mirror of https://github.com/golang/go synced 2024-11-18 15:24:41 -07:00

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>
This commit is contained in:
Pontus Leitzler 2020-08-05 01:21:24 +02:00 committed by Rebecca Stambler
parent 6f4f008689
commit 3e8281990c

View File

@ -23,7 +23,10 @@ func GCOptimizationDetails(ctx context.Context, snapshot Snapshot, pkgDir span.U
if err := os.MkdirAll(outDir, 0700); err != nil { if err := os.MkdirAll(outDir, 0700); err != nil {
return nil, err 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) err := snapshot.RunGoCommandDirect(ctx, "build", args)
if err != nil { if err != nil {
return nil, err return nil, err