1
0
mirror of https://github.com/golang/go synced 2024-11-24 08:20:03 -07:00

cmd/go: add more env variables to "go bug"

CL 31330 added more envvars to "go env".
This CL brings them to "go bug" as well.

Change-Id: Iae122072c8178007eda8b765aaa3f38c3c6e39a0
Reviewed-on: https://go-review.googlesource.com/32011
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Josh Bleecher Snyder 2016-10-25 11:45:26 -07:00
parent d8d445280a
commit 050f378085
2 changed files with 18 additions and 13 deletions

View File

@ -39,7 +39,9 @@ func runBug(cmd *Command, args []string) {
fmt.Fprint(&buf, "#### System details\n\n") fmt.Fprint(&buf, "#### System details\n\n")
fmt.Fprintln(&buf, "```") fmt.Fprintln(&buf, "```")
fmt.Fprintf(&buf, "go version %s %s/%s\n", runtime.Version(), runtime.GOOS, runtime.GOARCH) fmt.Fprintf(&buf, "go version %s %s/%s\n", runtime.Version(), runtime.GOOS, runtime.GOARCH)
for _, e := range mkEnv() { env := mkEnv()
env = append(env, extraEnvVars()...)
for _, e := range env {
fmt.Fprintf(&buf, "%s=\"%s\"\n", e.name, e.value) fmt.Fprintf(&buf, "%s=\"%s\"\n", e.name, e.value)
} }
printOSDetails(&buf) printOSDetails(&buf)

View File

@ -88,21 +88,24 @@ func findEnv(env []envVar, name string) string {
return "" return ""
} }
func runEnv(cmd *Command, args []string) { // extraEnvVars returns environment variables that should not leak into child processes.
env := mkEnv() func extraEnvVars() []envVar {
// Add these environment variables here so they do not leak
// into child processes.
var b builder var b builder
b.init() b.init()
cppflags, cflags, cxxflags, fflags, ldflags := b.cflags(&Package{}) cppflags, cflags, cxxflags, fflags, ldflags := b.cflags(&Package{})
env = append(env, return []envVar{
envVar{"PKG_CONFIG", b.pkgconfigCmd()}, {"PKG_CONFIG", b.pkgconfigCmd()},
envVar{"CGO_CFLAGS", strings.Join(cflags, " ")}, {"CGO_CFLAGS", strings.Join(cflags, " ")},
envVar{"CGO_CPPFLAGS", strings.Join(cppflags, " ")}, {"CGO_CPPFLAGS", strings.Join(cppflags, " ")},
envVar{"CGO_CXXFLAGS", strings.Join(cxxflags, " ")}, {"CGO_CXXFLAGS", strings.Join(cxxflags, " ")},
envVar{"CGO_FFLAGS", strings.Join(fflags, " ")}, {"CGO_FFLAGS", strings.Join(fflags, " ")},
envVar{"CGO_LDFLAGS", strings.Join(ldflags, " ")}, {"CGO_LDFLAGS", strings.Join(ldflags, " ")},
) }
}
func runEnv(cmd *Command, args []string) {
env := mkEnv()
env = append(env, extraEnvVars()...)
if len(args) > 0 { if len(args) > 0 {
for _, name := range args { for _, name := range args {
fmt.Printf("%s\n", findEnv(env, name)) fmt.Printf("%s\n", findEnv(env, name))