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 <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
diff --git a/misc/cgo/testcarchive/carchive_test.go b/misc/cgo/testcarchive/carchive_test.go
index dbde92d..74897c7 100644
--- a/misc/cgo/testcarchive/carchive_test.go
+++ b/misc/cgo/testcarchive/carchive_test.go
@@ -115,8 +115,10 @@
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))