From 3519aa25b86f6f26353801ead2372efc783d75e3 Mon Sep 17 00:00:00 2001 From: "Hana (Hyang-Ah) Kim" Date: Tue, 2 Aug 2022 23:24:30 -0400 Subject: [PATCH] internal/lsp/cmd: remove unused Env from pkgLoadConfig Instead rely on the process env vars the `gopls vulncheck` command runs with. Change-Id: I313a035d9bb7dbbdf2199474e0864cdb591e15ab Reviewed-on: https://go-review.googlesource.com/c/tools/+/420996 TryBot-Result: Gopher Robot Reviewed-by: Suzy Mueller Run-TryBot: Hyang-Ah Hana Kim Reviewed-by: Robert Findley gopls-CI: kokoro --- internal/lsp/cmd/vulncheck.go | 12 +----------- internal/lsp/command.go | 5 ----- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/internal/lsp/cmd/vulncheck.go b/internal/lsp/cmd/vulncheck.go index 19b3466a53..d5b05a9242 100644 --- a/internal/lsp/cmd/vulncheck.go +++ b/internal/lsp/cmd/vulncheck.go @@ -27,10 +27,6 @@ type pkgLoadConfig struct { // the build system's query tool. BuildFlags []string - // Env is the environment to use when invoking the build system's query tool. - // If Env is nil, the current environment is used. - Env []string - // If Tests is set, the loader includes related test packages. Tests bool } @@ -65,11 +61,6 @@ func (v *vulncheck) Run(ctx context.Context, args ...string) error { if len(args) == 1 { pattern = args[0] } - - cwd, err := os.Getwd() - if err != nil { - return tool.CommandLineErrorf("failed to get current directory: %v", err) - } var cfg pkgLoadConfig if v.Config { if err := json.NewDecoder(os.Stdin).Decode(&cfg); err != nil { @@ -87,8 +78,7 @@ func (v *vulncheck) Run(ctx context.Context, args ...string) error { Context: ctx, Tests: cfg.Tests, BuildFlags: cfg.BuildFlags, - Env: cfg.Env, - Dir: cwd, + // inherit the current process's cwd and env. } res, err := opts.Hooks.Govulncheck(ctx, loadCfg, pattern) diff --git a/internal/lsp/command.go b/internal/lsp/command.go index 6df909bdb1..f830a97c98 100644 --- a/internal/lsp/command.go +++ b/internal/lsp/command.go @@ -797,11 +797,6 @@ type pkgLoadConfig struct { // the build system's query tool. BuildFlags []string - // Env is the environment to use when invoking the build system's query tool. - // If Env is nil, the current environment is used. - // TODO: This seems unnecessary. Delete. - Env []string - // If Tests is set, the loader includes related test packages. Tests bool }