pointer based map sorting

This commit is contained in:
Arpad Ryszka 2020-12-06 23:37:18 +01:00
parent fd0a780a76
commit e27cfd9354
2 changed files with 7 additions and 7 deletions

View File

@ -24,7 +24,7 @@ const (
skipTypes
allTypes
randomMaps
pointerValues
_pointerValues // used only internally
)
type wrapLen struct {

View File

@ -144,7 +144,7 @@ func reflectMap(o opts, p *pending, r reflect.Value) node {
sn := make(map[string]node)
for _, key := range r.MapKeys() {
kn := reflectValue(itemOpts, p, key)
knExt := reflectValue(allTypes|pointerValues, p, key)
knExt := reflectValue(itemOpts|_pointerValues, p, key)
var b bytes.Buffer
wr := writer{w: &b}
fprint(&wr, 0, knExt)
@ -180,15 +180,15 @@ func reflectPointer(o opts, p *pending, r reflect.Value) node {
}
e := reflectValue(o, p, r.Elem())
if o & _pointerValues != 0 {
e = nodeOf(e, "_", r.Pointer())
}
if _, t, _ := withType(o); !t {
return e
}
if o&pointerValues == 0 {
return nodeOf("*", e)
}
return nodeOf("*(", r.Pointer(), ")", e)
}
func reflectList(o opts, p *pending, r reflect.Value) node {