@@ -72,29 +72,28 @@ const (
72
72
//
73
73
// Notes on the value:
74
74
//
75
- // * Unexported fields on structs are ignored and do not affect the
75
+ // - Unexported fields on structs are ignored and do not affect the
76
76
// hash value.
77
77
//
78
- // * Adding an exported field to a struct with the zero value will change
78
+ // - Adding an exported field to a struct with the zero value will change
79
79
// the hash value.
80
80
//
81
81
// For structs, the hashing can be controlled using tags. For example:
82
82
//
83
- // struct {
84
- // Name string
85
- // UUID string `hash:"ignore"`
86
- // }
83
+ // struct {
84
+ // Name string
85
+ // UUID string `hash:"ignore"`
86
+ // }
87
87
//
88
88
// The available tag values are:
89
89
//
90
- // * "ignore" or "-" - The field will be ignored and not affect the hash code.
90
+ // - "ignore" or "-" - The field will be ignored and not affect the hash code.
91
91
//
92
- // * "set" - The field will be treated as a set, where ordering doesn't
93
- // affect the hash code. This only works for slices.
94
- //
95
- // * "string" - The field will be hashed as a string, only works when the
96
- // field implements fmt.Stringer
92
+ // - "set" - The field will be treated as a set, where ordering doesn't
93
+ // affect the hash code. This only works for slices.
97
94
//
95
+ // - "string" - The field will be hashed as a string, only works when the
96
+ // field implements fmt.Stringer
98
97
func Hash (v interface {}, format Format , opts * HashOptions ) (uint64 , error ) {
99
98
// Validate our format
100
99
if format <= formatInvalid || format >= formatMax {
@@ -422,7 +421,6 @@ func (w *walker) visit(v reflect.Value, opts *visitOpts) (uint64, error) {
422
421
default :
423
422
return 0 , fmt .Errorf ("unknown kind to hash: %s" , k )
424
423
}
425
-
426
424
}
427
425
428
426
func hashUpdateOrdered (h hash.Hash64 , a , b uint64 ) uint64 {
@@ -453,11 +451,11 @@ func hashUpdateUnordered(a, b uint64) uint64 {
453
451
// hashUpdateUnordered can effectively cancel out a previous change to the hash
454
452
// result if the same hash value appears later on. For example, consider:
455
453
//
456
- // hashUpdateUnordered(hashUpdateUnordered("A", "B"), hashUpdateUnordered("A", "C")) =
457
- // H("A") ^ H("B")) ^ (H("A") ^ H("C")) =
458
- // (H("A") ^ H("A")) ^ (H("B") ^ H(C)) =
459
- // H(B) ^ H(C) =
460
- // hashUpdateUnordered(hashUpdateUnordered("Z", "B"), hashUpdateUnordered("Z", "C"))
454
+ // hashUpdateUnordered(hashUpdateUnordered("A", "B"), hashUpdateUnordered("A", "C")) =
455
+ // H("A") ^ H("B")) ^ (H("A") ^ H("C")) =
456
+ // (H("A") ^ H("A")) ^ (H("B") ^ H(C)) =
457
+ // H(B) ^ H(C) =
458
+ // hashUpdateUnordered(hashUpdateUnordered("Z", "B"), hashUpdateUnordered("Z", "C"))
461
459
//
462
460
// hashFinishUnordered "hardens" the result, so that encountering partially
463
461
// overlapping input data later on in a different context won't cancel out.
0 commit comments