File: hashstructure_examples_test.go

package info (click to toggle)
golang-github-mitchellh-hashstructure 0.0~git20160209.0.6b17d66-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 76 kB
  • ctags: 27
  • sloc: makefile: 4
file content (32 lines) | stat: -rw-r--r-- 476 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package hashstructure

import (
	"fmt"
)

func ExampleHash() {
	type ComplexStruct struct {
		Name     string
		Age      uint
		Metadata map[string]interface{}
	}

	v := ComplexStruct{
		Name: "mitchellh",
		Age:  64,
		Metadata: map[string]interface{}{
			"car":      true,
			"location": "California",
			"siblings": []string{"Bob", "John"},
		},
	}

	hash, err := Hash(v, nil)
	if err != nil {
		panic(err)
	}

	fmt.Printf("%d", hash)
	// Output:
	// 8669281753891521642
}