format arrays without panicking
diff --git a/formatter.go b/formatter.go
index 420729b..1161de7 100644
--- a/formatter.go
+++ b/formatter.go
@@ -185,11 +185,11 @@
if showType {
io.WriteString(p, t.String())
}
- if v.IsNil() && showType {
+ if v.Kind() == reflect.Slice && v.IsNil() && showType {
io.WriteString(p, "(nil)")
break
}
- if v.IsNil() {
+ if v.Kind() == reflect.Slice && v.IsNil() {
io.WriteString(p, "nil")
break
}
diff --git a/formatter_test.go b/formatter_test.go
index 7f25f71..303f033 100644
--- a/formatter_test.go
+++ b/formatter_test.go
@@ -40,6 +40,7 @@
{1, "int(1)"},
{1.0, "float64(1)"},
{[]int(nil), "[]int(nil)"},
+ {[0]int{}, "[0]int{}"},
{complex(1, 0), "(1+0i)"},
//{make(chan int), "(chan int)(0x1234)"},
{unsafe.Pointer(uintptr(1)), "unsafe.Pointer(0x1)"},