-
Notifications
You must be signed in to change notification settings - Fork 28
Open
Labels
Description
Currently the hash only includes the fields of a struct and not the name of the struct type. This causes potentially unwanted hash collisions as seen below:
type TypeA struct {
Foo string
Bar string
}
type TypeB struct {
Foo string
Bar string
}
func TestTags(t *testing.T) {
t1 := TypeA{"foo", "bar"}
t2 := TypeB{"foo", "bar"}
h1, err := Hash(t1, 1)
if err != nil {
panic(err)
}
h2, err := Hash(t2, 1)
if err != nil {
panic(err)
}
if h1 == h2 {
t.Error("hash collision")
}
}