global_id.go 308 B

1234567891011121314151617
  1. package utils
  2. import (
  3. "hash/maphash"
  4. "unsafe"
  5. )
  6. var globalSeed = maphash.MakeSeed()
  7. func GlobalID(material string) (id [8]byte) {
  8. *(*uint64)(unsafe.Pointer(&id[0])) = maphash.String(globalSeed, material)
  9. return
  10. }
  11. func MapHash(material string) uint64 {
  12. return maphash.String(globalSeed, material)
  13. }