internal/lsp/cache: copy *packages.Config environment completely

I noticed a race in these logs:
https://build.golang.org/log/ec2915e97319de219284ed022338f2ebc549aff6.

We need to copy the environment and build flags for each config, since
we're treating the config as single use.

Change-Id: I9e717e688def088cb60f2b23b71d731e2b20b259
Reviewed-on: https://go-review.googlesource.com/c/tools/+/244118
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
Rebecca Stambler 2020-07-21 20:08:27 -04:00
parent 80cb79702c
commit b3d141ddef
1 changed files with 3 additions and 3 deletions

View File

@ -107,10 +107,10 @@ func (s *snapshot) config(ctx context.Context) *packages.Config {
s.view.optionsMu.Unlock()
cfg := &packages.Config{
Env: env,
Dir: s.view.folder.Filename(),
Context: ctx,
BuildFlags: buildFlags,
Dir: s.view.folder.Filename(),
Env: append([]string{}, env...),
BuildFlags: append([]string{}, buildFlags...),
Mode: packages.NeedName |
packages.NeedFiles |
packages.NeedCompiledGoFiles |