hashstructure
hashstructure copied to clipboard
Different slice in struct result in the same hash
Here's how to reproduce it:
package main
import (
"fmt"
"github.com/mitchellh/hashstructure/v2"
)
type TempStruct struct {
Strings []string `hash:"set"`
}
func main() {
channelIds := &[]string{
"66693f7ecdd2e6e2b6f30c18", "66693f7ecdd2e6e2b6f30c19",
}
structt := TempStruct{Strings: *channelIds}
hashInt, _ := hashstructure.Hash(structt, hashstructure.FormatV2,
&hashstructure.HashOptions{SlicesAsSets: true})
channelIds1 := &[]string{
"66759857b42b04c45ed0c6e6", "66759857b42b04c45ed0c6e7",
}
struct1 := TempStruct{Strings: *channelIds1}
hashInt1, _ := hashstructure.Hash(struct1, hashstructure.FormatV2, nil)
fmt.Println(hashInt)
fmt.Print(hashInt1)
}
which will print:
4385387346745637338
4385387346745637338