<commit_before>package structhash

import (
	"fmt"
)

func ExampleHash() {
	type Person struct {
		Name   string
		Age    int
		Emails []string
		Extra  map[string]string
		Spouse *Person
	}
	bill := &Person{
		Name:   "Bill",
		Age:    24,
		Emails: []string{"<EMAIL>", "<EMAIL>"},
		Extra: map[string]string{
			"facebook": "Bob42",
		},
	}
	bob := &Person{
		Name:   "Bob",
		Age:    42,
		Emails: []string{"<EMAIL>", "<EMAIL>"},
		Extra: map[string]string{
			"facebook": "Bob42",
		},
		Spouse: bill,
	}

	hash, err := Hash(bob, 1)
	if err != nil {
		panic(err)
	}
	fmt.Printf("%s", hash)
	// Output:
	// v1_55743877f3ffd5fc834e97bc43a6e7bd
}

func ExampleHash_version() {
	type Person struct {
		Name   string            `version:"1"`
		Age    int               `version:"1"`
		Emails []string          `version:"1"`
		Extra  map[string]string `version:"1" lastversion:"2"`
		Spouse *Person           `version:"2"`
	}
	bill := &Person{
		Name:   "Bill",
		Age:    24,
		Emails: []string{"<EMAIL>", "<EMAIL>"},
		Extra: map[string]string{
			"facebook": "Bob42",
		},
	}
	bob := &Person{
		Name:   "Bob",
		Age:    42,
		Emails: []string{"<EMAIL>", "<EMAIL>"},
		Extra: map[string]string{
			"facebook": "Bob42",
		},
		Spouse: bill,
	}
	hashV1, err := Hash(bob, 1)
	if err != nil {
		panic(err)
	}
	hashV2, err := Hash(bob, 2)
	if err != nil {
		panic(err)
	}
	hashV3, err := Hash(bob, 3)
	if err != nil {
		panic(err)
	}
	fmt.Printf("%s\n", hashV1)
	fmt.Printf("%s\n", hashV2)
	fmt.Printf("%s\n", hashV3)
	// Output:
	// v1_461558d2570e10f79693e34ea309d1ad
	// v2_d00068b9441e09d87689c7cb06a646a1
	// v3_b5b651c6650939ef4d063d05caa5c778
}

func ExampleVersion() {
	// A hash string gotten from Hash(). Returns the version as an int.
	i := Version("v1_55743877f3ffd5fc834e97bc43a6e7bd")
	fmt.Printf("%d", i)
	// Output:
	// 1
}

func ExampleVersion_errors() {<commit_msg>Add ExampleDump()<commit_after>package structhash

import (
	"fmt"
	"crypto/md5"
	"crypto/sha1"
)

func ExampleHash() {
	type Person struct {
		Name   string
		Age    int
		Emails []string
		Extra  map[string]string
		Spouse *Person
	}
	bill := &Person{
		Name:   "Bill",
		Age:    24,
		Emails: []string{"<EMAIL>", "<EMAIL>"},
		Extra: map[string]string{
			"facebook": "Bob42",
		},
	}
	bob := &Person{
		Name:   "Bob",
		Age:    42,
		Emails: []string{"<EMAIL>", "<EMAIL>"},
		Extra: map[string]string{
			"facebook": "Bob42",
		},
		Spouse: bill,
	}

	hash, err := Hash(bob, 1)
	if err != nil {
		panic(err)
	}
	fmt.Printf("%s", hash)
	// Output:
	// v1_55743877f3ffd5fc834e97bc43a6e7bd
}

func ExampleHash_version() {
	type Person struct {
		Name   string            `version:"1"`
		Age    int               `version:"1"`
		Emails []string          `version:"1"`
		Extra  map[string]string `version:"1" lastversion:"2"`
		Spouse *Person           `version:"2"`
	}
	bill := &Person{
		Name:   "Bill",
		Age:    24,
		Emails: []string{"<EMAIL>", "<EMAIL>"},
		Extra: map[string]string{
			"facebook": "Bob42",
		},
	}
	bob := &Person{
		Name:   "Bob",
		Age:    42,
		Emails: []string{"<EMAIL>", "<EMAIL>"},
		Extra: map[string]string{
			"facebook": "Bob42",
		},
		Spouse: bill,
	}
	hashV1, err := Hash(bob, 1)
	if err != nil {
		panic(err)
	}
	hashV2, err := Hash(bob, 2)
	if err != nil {
		panic(err)
	}
	hashV3, err := Hash(bob, 3)
	if err != nil {
		panic(err)
	}
	fmt.Printf("%s\n", hashV1)
	fmt.Printf("%s\n", hashV2)
	fmt.Printf("%s\n", hashV3)
	// Output:
	// v1_461558d2570e10f79693e34ea309d1ad
	// v2_d00068b9441e09d87689c7cb06a646a1
	// v3_b5b651c6650939ef4d063d05caa5c778
}

func ExampleDump() {
	type Person struct {
		Name   string
		Age    int
		Emails []string
		Extra  map[string]string
		Spouse *Person
	}
	bill := &Person{
		Name:   "Bill",
		Age:    24,
		Emails: []string{"<EMAIL>", "<EMAIL>"},
		Extra: map[string]string{
			"facebook": "Bob42",
		},
	}
	bob := &Person{
		Name:   "Bob",
		Age:    42,
		Emails: []string{"<EMAIL>", "<EMAIL>"},
		Extra: map[string]string{
			"facebook": "Bob42",
		},
		Spouse: bill,
	}

	fmt.Printf("md5:  %x\n", md5.Sum(Dump(bob, 1)))
	fmt.Printf("sha1: %x\n", sha1.Sum(Dump(bob, 1)))
	// Output:
	// md5:  d00068b9441e09d87689c7cb06a646a1
	// sha1: 24c19cd7a9fcfd4d4394e1f6a1874bd8751645e3
}

func ExampleVersion() {
	// A hash string gotten from Hash(). Returns the version as an int.
	i := Version("v1_55743877f3ffd5fc834e97bc43a6e7bd")
	fmt.Printf("%d", i)
	// Output:
	// 1
}

func ExampleVersion_errors() {
{'fraction_non_alphanumeric': 0.18198157717366883, 'fraction_numerical': 0.07908335205571781, 'mean_word_length': 3.2239089184060723, 'pattern_counts': {'":': 10, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2823357', 'n_tokens_mistral': 2220, 'n_tokens_neox': 1918, 'n_words': 387}