From 0d33dc3105734dcd262c3104076e05a363b802b1 Mon Sep 17 00:00:00 2001 From: Todd Neal Date: Fri, 7 Apr 2017 15:41:19 -0500 Subject: runtime: improve output of panic(x) where x is numeric Fixes #19658 Change-Id: I41e46073b75c7674e2ed9d6a90ece367ce92166b Reviewed-on: https://go-review.googlesource.com/39650 Run-TryBot: Todd Neal TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- src/runtime/error.go | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'src/runtime/error.go') diff --git a/src/runtime/error.go b/src/runtime/error.go index f5b015c091..eafcc9b173 100644 --- a/src/runtime/error.go +++ b/src/runtime/error.go @@ -74,8 +74,6 @@ func typestring(x interface{}) string { // For calling from C. // Prints an argument passed to panic. -// There's room for arbitrary complexity here, but we keep it -// simple and handle just a few important cases: int, string, and Stringer. func printany(i interface{}) { switch v := i.(type) { case nil: @@ -84,8 +82,38 @@ func printany(i interface{}) { print(v.String()) case error: print(v.Error()) + case bool: + print(v) case int: print(v) + case int8: + print(v) + case int16: + print(v) + case int32: + print(v) + case int64: + print(v) + case uint: + print(v) + case uint8: + print(v) + case uint16: + print(v) + case uint32: + print(v) + case uint64: + print(v) + case uintptr: + print(v) + case float32: + print(v) + case float64: + print(v) + case complex64: + print(v) + case complex128: + print(v) case string: print(v) default: -- cgit v1.3-5-g9baa