Source file
src/hash/maphash/example_test.go
1
2
3
4
5 package maphash_test
6
7 import (
8 "fmt"
9 "hash/maphash"
10 )
11
12 func Example() {
13
14
15 var h maphash.Hash
16
17
18 h.WriteString("hello, ")
19 fmt.Printf("%#x\n", h.Sum64())
20
21
22 h.Write([]byte{'w', 'o', 'r', 'l', 'd'})
23 fmt.Printf("%#x\n", h.Sum64())
24
25
26
27 h.Reset()
28
29
30
31 var h2 maphash.Hash
32 h2.SetSeed(h.Seed())
33
34 h.WriteString("same")
35 h2.WriteString("same")
36 fmt.Printf("%#x == %#x\n", h.Sum64(), h2.Sum64())
37 }
38
View as plain text