diff options
| author | Patrick Mezard <[email protected]> | 2013-10-27 23:44:49 +0100 |
|---|---|---|
| committer | Patrick Mezard <[email protected]> | 2013-10-27 23:44:49 +0100 |
| commit | 1fdf49f1b9ce7ab182b1b38bbc847b9807f66f3a (patch) | |
| tree | 3bdd47a30426d70c79c8b9c66f16e42a620eff00 /spew/config.go | |
| parent | 1fe9f5ca4b46a8247ae5939097f5cfc5d8370729 (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/config.go')
| -rw-r--r-- | spew/config.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/spew/config.go b/spew/config.go index a2eab61..1faca1b 100644 --- a/spew/config.go +++ b/spew/config.go @@ -73,6 +73,12 @@ type ConfigState struct { // NOTE: This flag does not have any effect if method invocation is disabled // via the DisableMethods or DisablePointerMethods options. ContinueOnMethod bool + + // SortKeys specifies map keys should be sorted before being printed. Use + // this to have a more deterministic, diffable output. Note that only + // native types (bool, int, uint, floats, uintptr and string) are supported, + // other key sequences will displayed in the original order. + SortKeys bool } // Config is the active configuration of the top-level functions. |
