From 04cdfd42973bb9c8589fd6a731800cf222fde1a9 Mon Sep 17 00:00:00 2001 From: Alexander Staubo Date: Fri, 28 Oct 2016 13:58:48 -0400 Subject: Adds new config options: DisablePointerAddresses: Specifies whether to disable the printing of pointer addresses. DisableCapacities specifies whether to disable the printing of capacities for arrays, slices, maps and channels. These are useful when diffing data structures in tests. Printing pointers and capacities would otherwise lead to false negatives. --- spew/dump.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'spew/dump.go') diff --git a/spew/dump.go b/spew/dump.go index a0ff95e..95f9dbf 100644 --- a/spew/dump.go +++ b/spew/dump.go @@ -129,7 +129,7 @@ func (d *dumpState) dumpPtr(v reflect.Value) { d.w.Write(closeParenBytes) // Display pointer information. - if len(pointerChain) > 0 { + if !d.cs.DisablePointerAddresses && len(pointerChain) > 0 { d.w.Write(openParenBytes) for i, addr := range pointerChain { if i > 0 { @@ -282,13 +282,13 @@ func (d *dumpState) dump(v reflect.Value) { case reflect.Map, reflect.String: valueLen = v.Len() } - if valueLen != 0 || valueCap != 0 { + if valueLen != 0 || !d.cs.DisableCapacities && valueCap != 0 { d.w.Write(openParenBytes) if valueLen != 0 { d.w.Write(lenEqualsBytes) printInt(d.w, int64(valueLen), 10) } - if valueCap != 0 { + if !d.cs.DisableCapacities && valueCap != 0 { if valueLen != 0 { d.w.Write(spaceBytes) } -- cgit v1.2.3