github.com/gogf/gf@v1.16.9/.example/encoding/ghash/ghash_repeat_check.go (about)

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  	"strconv"
     6  
     7  	"github.com/gogf/gf/encoding/ghash"
     8  )
     9  
    10  func main() {
    11  	m := make(map[uint64]bool)
    12  	for i := 0; i < 100000000; i++ {
    13  		hash := ghash.BKDRHash64([]byte("key_" + strconv.Itoa(i)))
    14  		if _, ok := m[hash]; ok {
    15  			fmt.Printf("duplicated hash %d\n", hash)
    16  		} else {
    17  			m[hash] = true
    18  		}
    19  	}
    20  }