hashutils

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2020 License: Apache-2.0 Imports: 5 Imported by: 48

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashAll

func HashAll(values ...interface{}) uint64

hash one or more values order matters Deprecated, use safe HashAllSafe

func HashAllSafe added in v0.11.1

func HashAllSafe(hasher hash.Hash64, values ...interface{}) (uint64, error)

hash one or more values order matters

This function returns the hashed result of all values passed into it. Any objects passed into it which fulfill the SafeHasher interface will be hashed this was, or using reflection if not. SafeHasher should be preferred. If no hasher is provided one will be provided. If a hasher is passed in, the returned hash can be ignored in favor of the hasher.

func HashableEqual added in v0.11.2

func HashableEqual(val1 interface{}, val2 interface{}) (equal bool, ok bool)

This function takes in any number of resources and attempts to compare them as safe hashers. If any are not safe hashers it will return !ok. If they are all safe hashers, it will compare the equality of all of them

func MustHash added in v0.11.6

func MustHash(val interface{}) uint64

This function will hash anything, and panic if it fails. If the object is a `SafeHasher` than it will use the generated Hasher, otherwise it will use the hashstructure library.

Types

type Hasher

type Hasher interface {
	Hash() uint64
}

Hashers are resources which have a custom hashing function defined. Hash functions are generated by default for go-utils resources Deprecated, use safe Hasher

type SafeHasher added in v0.11.1

type SafeHasher interface {
	Hash(hasher hash.Hash64) (uint64, error)
}

Directories

Path Synopsis
Package mock_hashutils is a generated GoMock package.
Package mock_hashutils is a generated GoMock package.

Jump to

Keyboard shortcuts

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