summaryrefslogtreecommitdiff
path: root/spew/format.go
diff options
context:
space:
mode:
authorPatrick Mezard <[email protected]>2013-10-27 23:44:49 +0100
committerPatrick Mezard <[email protected]>2013-10-27 23:44:49 +0100
commit1fdf49f1b9ce7ab182b1b38bbc847b9807f66f3a (patch)
tree3bdd47a30426d70c79c8b9c66f16e42a620eff00 /spew/format.go
parent1fe9f5ca4b46a8247ae5939097f5cfc5d8370729 (diff)
config: add SortKeys option to sort native map keys before display
If ConfigState.SortKeys is true, then dump and format will sort map keys before displaying them. Only native types (bool, ints, uint, uintptr, string) are supported, other slices are left unchanged. The motivation is to have more diffable output, mostly for test purpose.
Diffstat (limited to 'spew/format.go')
-rw-r--r--spew/format.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/spew/format.go b/spew/format.go
index 70785fa..fc57fda 100644
--- a/spew/format.go
+++ b/spew/format.go
@@ -302,6 +302,9 @@ func (f *formatState) format(v reflect.Value) {
f.fs.Write(maxShortBytes)
} else {
keys := v.MapKeys()
+ if f.cs.SortKeys {
+ SortValues(keys)
+ }
for i, key := range keys {
if i > 0 {
f.fs.Write(spaceBytes)