From 2b7b26d7b060df5ebca40ab2e915cc1b4bfe4f09 Mon Sep 17 00:00:00 2001 From: Rohan Challa Date: Thu, 23 Jan 2020 10:49:38 -0500 Subject: [PATCH] internal/imports: add buildflags to ProcessEnv This change adds a buildflags variable to the ProcessEnv inside internal/imports. When you run go list with GO111MODULE=on to get information about the package you are in, it will add a go directive to your go.mod file if there is not one. With the tempModfile=on flag, there should be no changes to a user's go.mod file. Updates golang/go#36247 Change-Id: I817e4c46b4f433d0665fcb7585fcdf4f87049a38 Reviewed-on: https://go-review.googlesource.com/c/tools/+/215978 Run-TryBot: Rohan Challa TryBot-Result: Gobot Gobot Reviewed-by: Heschi Kreinick --- internal/lsp/cache/view.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/lsp/cache/view.go b/internal/lsp/cache/view.go index d480f2264ea..e7122d452ef 100644 --- a/internal/lsp/cache/view.go +++ b/internal/lsp/cache/view.go @@ -373,6 +373,12 @@ func (v *view) buildProcessEnv(ctx context.Context) (*imports.ProcessEnv, error) env.GOSUMDB = split[1] } } + if len(cfg.BuildFlags) > 0 { + if env.GOFLAGS != "" { + env.GOFLAGS += " " + } + env.GOFLAGS += strings.Join(cfg.BuildFlags, " ") + } return env, nil }