3 hashstructure is a Go library for creating a unique hash value
4 for arbitrary values in Go.
6 This can be used to key values in a hash (for use in a map, set, etc.)
7 that are complex. The most common use case is comparing two values without
8 sending data across the network, caching values locally (de-dup), and so on.
12 * Hash any arbitrary Go value, including complex types.
14 * Tag a struct field to ignore it and not affect the hash value.
16 * Tag a slice type struct field to treat it as a set where ordering
17 doesn't affect the hash code but the field itself is still taken into
18 account to create the hash value.
20 * Optionally specify a custom hash function to optimize for speed, collision
21 avoidance for your data set, etc.
28 $ go get github.com/mitchellh/hashstructure
33 For usage and examples see the [Godoc](http://godoc.org/github.com/mitchellh/hashstructure).
35 A quick code example is shown below:
38 type ComplexStruct struct {
41 Metadata map[string]interface{}
47 Metadata: map[string]interface{}{
49 "location": "California",
50 "siblings": []string{"Bob", "John"},
54 hash, err := hashstructure.Hash(v, nil)
59 fmt.Printf("%d", hash)
61 // 2307517237273902113