Closed woodliu closed 3 months ago
This project use a module maphash, It use the golang map internal struct to generate the hash value, as:
maphash
a := any(make(map[K]struct{})) i := (*mapiface)(unsafe.Pointer(&a)) h = i.typ.hasher
And there are some comments like:
//go:build go1.18 || go1.19 // +build go1.18 go1.19
If the map internal struct changed in the future, that convert will fail.
How about just use the map address as the hash value like:
m := any(make(map[int]struct{})) p := uintptr(unsafe.Pointer(&m)) fmt.Println(p)
Or extract the hasher from goland: func typehash(t *abi.Type, p unsafe.Pointer, h uintptr) uintptr
func typehash(t *abi.Type, p unsafe.Pointer, h uintptr) uintptr
This project use a module
maphash
, It use the golang map internal struct to generate the hash value, as:And there are some comments like:
If the map internal struct changed in the future, that convert will fail.
How about just use the map address as the hash value like:
Or extract the hasher from goland:
func typehash(t *abi.Type, p unsafe.Pointer, h uintptr) uintptr