From: Ian Lance Taylor Date: Wed, 24 May 2017 21:59:22 +0000 (-0700) Subject: misc/cgo/testcarchive: fix `go env` error message X-Git-Tag: go1.9beta1~162 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=994b7eebc7e704b7132e5a69be72ca885b30b83e;p=gostls13.git misc/cgo/testcarchive: fix `go env` error message Add a missing newline. Don't panic on an unexpected error type. Change-Id: I82a4b12c498fbfdf4972737329631c0c02540005 Reviewed-on: https://go-review.googlesource.com/44092 Run-TryBot: Ian Lance Taylor TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- diff --git a/misc/cgo/testcarchive/carchive_test.go b/misc/cgo/testcarchive/carchive_test.go index dbde92d744..74897c7f6f 100644 --- a/misc/cgo/testcarchive/carchive_test.go +++ b/misc/cgo/testcarchive/carchive_test.go @@ -115,8 +115,10 @@ func init() { func goEnv(key string) string { out, err := exec.Command("go", "env", key).Output() if err != nil { - fmt.Fprintf(os.Stderr, "go env %s failed:\n%s", key, err) - fmt.Fprintf(os.Stderr, "%s", err.(*exec.ExitError).Stderr) + fmt.Fprintf(os.Stderr, "go env %s failed:\n%s\n", key, err) + if ee, ok := err.(*exec.ExitError); ok { + fmt.Fprintf(os.Stderr, "%s", ee.Stderr) + } os.Exit(2) } return strings.TrimSpace(string(out))