mirror of
https://github.com/hanzoai/tasks.git
synced 2026-11-03 03:56:04 +00:00
## What changed? Integrate Go 1.26's new `go fix` into workflow. NOTE that the changes caused our linter to fire; a [separate commit](https://github.com/temporalio/temporal/pull/9337/commits/1b23f787aef370098b35829c4d17dcc06230b4c1) addresses those. ## Why? Ensure Go code is standardized/modernized. ## How did you test it? - [ ] built - [ ] run locally and tested manually - [x] covered by existing tests - [ ] added new unit test(s) - [ ] added new functional test(s)
26 lines
509 B
Go
26 lines
509 B
Go
package collection
|
|
|
|
import (
|
|
"encoding/binary"
|
|
"encoding/hex"
|
|
)
|
|
|
|
// UUIDHashCode is a hash function for hashing string uuid
|
|
// if the uuid is malformed, then the hash function always
|
|
// returns 0 as the hash value
|
|
func UUIDHashCode(input any) uint32 {
|
|
key, ok := input.(string)
|
|
if !ok {
|
|
return 0
|
|
}
|
|
if len(key) != UUIDStringLength {
|
|
return 0
|
|
}
|
|
// Use the first 4 bytes of the uuid as the hash
|
|
b, err := hex.DecodeString(key[:8])
|
|
if err != nil {
|
|
return 0
|
|
}
|
|
return binary.BigEndian.Uint32(b)
|
|
}
|