From 2c357d306629fe59b953d9aa98f582de5956b32b Mon Sep 17 00:00:00 2001 From: Dan Kortschak Date: Fri, 27 Aug 2021 15:43:43 +0930 Subject: [PATCH] utter: improve non-pointer cycle rendering This makes it consistent with the pointer case. --- dump.go | 12 ++++++------ dump_test.go | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dump.go b/dump.go index 31d3ee7..e1174f6 100644 --- a/dump.go +++ b/dump.go @@ -89,10 +89,10 @@ func (d *dumpState) unpackValue(v reflect.Value) (val reflect.Value, wasPtr, sta // dumpPtr handles formatting of pointers by indirecting them as necessary. func (d *dumpState) dumpPtr(v reflect.Value) { - // Remove pointers at or below the current depth from map used to detect + // Remove pointers below the current depth from map used to detect // circular refs. for k, depth := range d.pointers { - if depth >= d.depth { + if depth > d.depth { delete(d.pointers, k) } } @@ -438,10 +438,10 @@ func (d *dumpState) dump(v reflect.Value, wasPtr, static bool, addr uintptr) { d.dumpSlice(v) break } - // Remove pointers at or below the current depth from map used to detect + // Remove pointers below the current depth from map used to detect // circular refs. for k, depth := range d.pointers { - if depth >= d.depth { + if depth > d.depth { delete(d.pointers, k) } } @@ -480,10 +480,10 @@ func (d *dumpState) dump(v reflect.Value, wasPtr, static bool, addr uintptr) { break } - // Remove pointers at or below the current depth from map used to detect + // Remove pointers below the current depth from map used to detect // circular refs. for k, depth := range d.pointers { - if depth >= d.depth { + if depth > d.depth { delete(d.pointers, k) } } diff --git a/dump_test.go b/dump_test.go index 5e35e9e..2b233da 100644 --- a/dump_test.go +++ b/dump_test.go @@ -1019,7 +1019,7 @@ var sliceElementCycles = []struct { return &r }(), want: `&[]interface{}{ - &[]interface{}(), + (*[]interface{})(), } `, }, @@ -1131,7 +1131,7 @@ var mapElementCycles = []struct { return &r }(), want: `&map[int]interface{}{ - int(0): &map[int]interface{}(), + int(0): (*map[int]interface{})(), } `, },