fingerprint

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 9, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fingerprint

func Fingerprint(val Hashable) (string, error)

Fingerprint is a short-hand for creating a new Hasher, calling [Hashable.Hash] on the provided value (unless it is nil), and then returning the Hasher.Finish result.

func Map

func Map[K comparable, V any, H Hashable](m map[K]V, fn func(K, V) (string, H)) mapped[H]

Types

type Bool

type Bool bool

func (Bool) Hash

func (b Bool) Hash(h *Hasher) error

type Hashable

type Hashable interface {
	Hash(h *Hasher) error
}

type Hasher

type Hasher struct {
	// contains filtered or unexported fields
}

func New

func New() *Hasher

New returns a Hasher from the pool, ready to use.

func (*Hasher) Close

func (h *Hasher) Close()

Close returns this Hasher to the pool.

func (*Hasher) Finish

func (h *Hasher) Finish() string

Finish obtains this Hasher's current fingerprint. It does not change the underlying state of the Hasher.

func (*Hasher) Named

func (h *Hasher) Named(name string, vals ...Hashable) error

Named hashes a named list of values. This creates explicit grouping of the values, avoiding that the concatenation of two things has a different hash than those same two things one after the other.

type Int

type Int int

func (Int) Hash

func (i Int) Hash(h *Hasher) error

type List

type List[T Hashable] []T

func Cast

func Cast[E any, T ~[]E, H Hashable](slice T, fn func(E) H) List[H]

func (List[T]) Hash

func (l List[T]) Hash(h *Hasher) error

type String

type String string

func (String) Hash

func (s String) Hash(h *Hasher) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL