该散包是这很有帮助。请注意,这是对特定哈希实现的抽象。在软件包子目录中可以找到一些现成的。
例:
package mainimport ( "fmt" "hash/fnv")func hash(s string) uint32 { h := fnv.New32a() h.Write([]byte(s)) return h.Sum32()}func main() { fmt.Println(hash("HelloWorld")) fmt.Println(hash("HelloWorld."))}(也在这里)
输出:
926844193107706013



