MCPcopy Create free account
hub / github.com/cloudnative-pg/cloudnative-pg / DeepHashObject

Function DeepHashObject

pkg/utils/hash/hash.go:34–45  ·  view source on GitHub ↗

DeepHashObject writes specified object to hash using the spew library which follows pointers and prints actual values of the nested objects ensuring the hash does not change when a pointer changes.

(hasher hash.Hash, objectToWrite interface{})

Source from the content-addressed store, hash-verified

32// which follows pointers and prints actual values of the nested objects
33// ensuring the hash does not change when a pointer changes.
34func DeepHashObject(hasher hash.Hash, objectToWrite interface{}) error {
35 hasher.Reset()
36 printer := spew.ConfigState{
37 Indent: " ",
38 SortKeys: true,
39 DisableMethods: true,
40 SpewKeys: true,
41 }
42
43 _, err := printer.Fprintf(hasher, "%#v", objectToWrite)
44 return err
45}
46
47// ComputeHash returns a hash value calculated from the provided object.
48// The hash will be safe encoded to avoid bad words.

Callers 1

ComputeHashFunction · 0.85

Calls 1

ResetMethod · 0.45

Tested by

no test coverage detected