summaryrefslogtreecommitdiffstats
path: root/utils.go
blob: fe3263c0f336a55a29c563017277cb97e9d12461 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package cache

import (
	"hash/fnv"
)

// zero returns the zero value for the specified type.
func zero[T any]() T {
	var ret T

	return ret
}

// hash computes the 64-bit FNV-1a hash of the provided data.
func hash(data []byte) uint64 {
	hasher := fnv.New64()
	if _, err := hasher.Write(data); err != nil {
		panic(err)
	}

	return hasher.Sum64()
}