Documentation ¶
Overview ¶
Package basehash provides basic types to implement hash identifiers.
Index ¶
- type Hash128
- func (h Hash128) Base64() string
- func (h Hash128) Bytes() []byte
- func (h Hash128) Compare(other Hash128) int
- func (h Hash128) Equal(other Hash128) bool
- func (h Hash128) Format(s fmt.State, ch rune)
- func (h Hash128) Hi() uint64
- func (h Hash128) IsZero() bool
- func (h Hash128) Less(other Hash128) bool
- func (h Hash128) Lo() uint64
- func (h Hash128) MarshalJSON() ([]byte, error)
- func (h Hash128) MarshalText() ([]byte, error)
- func (h Hash128) PutBytes16(b *[16]byte)
- func (h Hash128) StringNoQuotes() string
- func (h Hash128) ToUUIDString() string
- func (h *Hash128) UnmarshalJSON(b []byte) error
- func (h *Hash128) UnmarshalText(text []byte) error
- func (h Hash128) Words() (hi, lo uint64)
- type Hash64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Hash128 ¶
type Hash128 struct {
// contains filtered or unexported fields
}
Hash128 represents a uint128 using two uint64s.
hi represents the most significant 64 bits and lo represents the least significant 64 bits.
func New128FromBytes ¶
New128FromBytes returns a Hash128 given by the bytes in b.
func New128FromString ¶
New128FromString returns a Hash128 given by the characters in s.
func (Hash128) Base64 ¶
Base64 returns the base64 FileID representation for inclusion into JSON payloads.
func (Hash128) Compare ¶
Compare returns an integer comparing two hashes lexicographically. The result will be 0 if h == other, -1 if h < other, and +1 if h > other.
func (Hash128) Format ¶
Format implements fmt.Formatter.
It accepts the formats 'd' (decimal), 'v' (value), 'x' (lowercase hexadecimal), and 'X' (uppercase hexadecimal).
Also supported is a subset of the package fmt's format flags, including '#' for leading zero in hexadecimal.
For any unsupported format, the value will be serialized using the gob codec.
func (Hash128) Less ¶
Less reports whether h is less than other.
The order defined here must be the same as the one used in "SELECT ... FOR UPDATE" queries, otherwise DB deadlocks may occur on concurrent updates, hence the casts to int64.
func (Hash128) MarshalJSON ¶
func (Hash128) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface, so we can marshal (from JSON) a map using a Hash128 as a key
func (Hash128) PutBytes16 ¶
PutBytes16 writes the 16 bytes into the provided array pointer.
func (Hash128) StringNoQuotes ¶
func (Hash128) ToUUIDString ¶
func (*Hash128) UnmarshalJSON ¶
func (*Hash128) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface, so we can unmarshal (from JSON) a map using a Hash128 as a key