Make DeepHashObject function deterministic.

This commit is contained in:
rsokolowski
2015-02-19 16:40:35 +01:00
parent 413e1dba7e
commit 14e93a112b
2 changed files with 25 additions and 21 deletions

View File

@@ -26,5 +26,6 @@ import (
// which follows pointers and prints actual values of the nested objects
// ensuring the hash does not change when a pointer changes.
func DeepHashObject(hasher hash.Hash, objectToWrite interface{}) {
spew.Fprintf(hasher, "%#v", objectToWrite)
printer := spew.ConfigState{Indent: " ", SortKeys: true}
printer.Fprintf(hasher, "%#v", objectToWrite)
}