1
0
mirror of https://github.com/golang/go synced 2024-11-18 16:54:43 -07:00

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 <rohan@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
This commit is contained in:
Rohan Challa 2020-01-23 10:49:38 -05:00
parent 45e69182d1
commit 2b7b26d7b0

View File

@ -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
}