gf/geg/encoding/ghash.go

20 lines
330 B
Go
Raw Normal View History

2017-11-23 10:21:28 +08:00
package main
import (
2019-04-03 00:03:46 +08:00
"fmt"
"github.com/gogf/gf/g/encoding/ghash"
"strconv"
2017-11-23 10:21:28 +08:00
)
2019-04-03 00:03:46 +08:00
func main() {
m := make(map[uint64]bool)
for i := 0; i < 100000000; i++ {
hash := ghash.BKDRHash64([]byte("key_" + strconv.Itoa(i)))
if _, ok := m[hash]; ok {
fmt.Printf("duplicated hash %d\n", hash)
} else {
m[hash] = true
}
}
2017-11-23 10:21:28 +08:00
}