I am writing a data structure that should hash an arbitrary object. The following function seems to crash if I give a intparameter.
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 parameter does not intresult in:
panic: binary.Write: invalid int type
What is the right way to do this?
source
share