Source File
xxhash.go
Belonging Package
go.opentelemetry.io/otel/attribute/internal/xxhash
// Copyright The OpenTelemetry Authors// SPDX-License-Identifier: Apache-2.0// Package xxhash provides a wrapper around the xxhash library for attribute hashing.package xxhash // import "go.opentelemetry.io/otel/attribute/internal/xxhash"import ()// Hash wraps xxhash.Digest to provide an API friendly for hashing attribute values.type Hash struct {d *xxhash.Digest}// New returns a new initialized xxHash64 hasher.func () Hash {return Hash{d: xxhash.New()}}func ( Hash) ( uint64) Hash {var [8]bytebinary.LittleEndian.PutUint64([:], )// errors from Write are always nil for xxhash// if it returns an err then panic, := .d.Write([:])if != nil {panic("xxhash write of uint64 failed: " + .Error())}return}func ( Hash) ( bool) Hash { // nolint:revive // This is a hashing function.if {return .Uint64(1)}return .Uint64(0)}func ( Hash) ( float64) Hash {return .Uint64(math.Float64bits())}func ( Hash) ( int64) Hash {return .Uint64(uint64()) // nolint:gosec // Overflow doesn't matter since we are hashing.}func ( Hash) ( string) Hash {// errors from WriteString are always nil for xxhash// if it returns an err then panic, := .d.WriteString()if != nil {panic("xxhash write of string failed: " + .Error())}return}// Sum64 returns the current hash value.func ( Hash) () uint64 {return .d.Sum64()}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |