forked from davecgh/go-spew
-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Labels
Description
Given an adequately clever parser and type constructor, we still cannot unambiguously recreate a data structure from the output of utter when there are pointers to non-pointer values.
In the case of pointers to concrete values, there is no address information given for the target, so for example:
c := []interface{}{5, 5, nil, nil}
c[2] = &c[0]
c[3] = &c[0]
ptrDump := utter.NewDefaultConfig()
ptrDump.CommentPointers = true
ptrDump(c)
gives:
[]interface{}{
int(5),
int(5),
&int /*0xc20803e840*/ (5),
&int /*0xc20803e840*/ (5),
}
To get this information and only report it where necessary we need to walk the structure once before the dump and mark concrete values that are referenced by a pointer.
Another complication is of how to deal with pointers into []byte. To not interfere with []byte formatting, I think the best approach is to add an appendix comment to []byte rendering to list elements that are referenced and their addresss.