summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--spew/dump.go9
-rw-r--r--spew/format.go9
2 files changed, 16 insertions, 2 deletions
diff --git a/spew/dump.go b/spew/dump.go
index 8dd8ca9..831715c 100644
--- a/spew/dump.go
+++ b/spew/dump.go
@@ -245,7 +245,14 @@ func (d *dumpState) dump(v reflect.Value) {
case reflect.Complex128:
printComplex(d.w, v.Complex(), 64)
- case reflect.Array, reflect.Slice:
+ case reflect.Slice:
+ if v.IsNil() {
+ d.w.Write(nilAngleBytes)
+ break
+ }
+ fallthrough
+
+ case reflect.Array:
d.w.Write(openBraceNewlineBytes)
d.depth++
if (d.cs.MaxDepth != 0) && (d.depth > d.cs.MaxDepth) {
diff --git a/spew/format.go b/spew/format.go
index f9b91ae..70785fa 100644
--- a/spew/format.go
+++ b/spew/format.go
@@ -256,7 +256,14 @@ func (f *formatState) format(v reflect.Value) {
case reflect.Complex128:
printComplex(f.fs, v.Complex(), 64)
- case reflect.Array, reflect.Slice:
+ case reflect.Slice:
+ if v.IsNil() {
+ f.fs.Write(nilAngleBytes)
+ break
+ }
+ fallthrough
+
+ case reflect.Array:
f.fs.Write(openBracketBytes)
f.depth++
if (f.cs.MaxDepth != 0) && (f.depth > f.cs.MaxDepth) {