I would like to generate a unique hash from an array of structs. The order might be different but the values are the same.
Example:
type MyStruct struct {
ID string
Parameters map[string]interface{}
}
arr:= []MyStruct{MyStruct{ID: "test", Parameters: map[string]interface{}{"key": true, "key2": "value"} }, MyStruct{ID: "test2", Parameters: map[string]interface{}{"key2": "value", "key": true} }}
//The order is different even inside the Parameters fields
arr:= []MyStruct{MyStruct{ID: "test2", Parameters: map[string]interface{}{"key2": "value", "key": true} },MyStruct{ID: "test", Parameters: map[string]interface{}{"key": true, "key2": "value"} }}
In both cases the hash should be the same since the values inside the structs are the same.
EDIT: Basically the idea is to generate a unique hash for caching! I want to combine the individual hash of each struct!