I am writing a data structure that needs to hash an arbitrary object. The following function seems to fail if I give an int
is the parameter.
func Hash( obj interface{} ) []byte {
digest := md5.New()
if err := binary.Write(digest, binary.LittleEndian, obj); err != nil {
panic(err)
}
return digest.Sum()
}
Calling this on an int
results in:
panic: binary.Write: invalid type int
What is the right way to do this?