fix nil slice format
diff --git a/formatter.go b/formatter.go
index f8ed18d..420729b 100644
--- a/formatter.go
+++ b/formatter.go
@@ -185,6 +185,14 @@
if showType {
io.WriteString(p, t.String())
}
+ if v.IsNil() && showType {
+ io.WriteString(p, "(nil)")
+ break
+ }
+ if v.IsNil() {
+ io.WriteString(p, "nil")
+ break
+ }
writeByte(p, '{')
expand := !canInline(v.Type())
pp := p
diff --git a/formatter_test.go b/formatter_test.go
index 223ae73..7f25f71 100644
--- a/formatter_test.go
+++ b/formatter_test.go
@@ -39,6 +39,7 @@
{"a", `"a"`},
{1, "int(1)"},
{1.0, "float64(1)"},
+ {[]int(nil), "[]int(nil)"},
{complex(1, 0), "(1+0i)"},
//{make(chan int), "(chan int)(0x1234)"},
{unsafe.Pointer(uintptr(1)), "unsafe.Pointer(0x1)"},