Deephash
Deep hashing for Go - able to calculate an fnv hash of nested data structures with exported fields.
Install / Use
/learn @davegardnerisme/DeephashREADME
Deep hash
A library for calculating a deterministic hash for simple or nested data structures
in Go. The traversal algorithm is based on mergo,
which is in turn based on reflect/deepequal.go from the stdlib.
Example:
eg1 := "foo"
eg2 := example{
Foo: "foo",
Bar: 43.0,
}
eg3 := &example{
Foo: "foo",
Bar: 43.0,
}
fmt.Printf("String\t%x\n", deephash.Hash(eg1))
fmt.Printf("Struct\t%x\n", deephash.Hash(eg2))
fmt.Printf("Pointer\t%x\n", deephash.Hash(eg3))
Output:
String dcb27518fed9d577
Struct e0979b89bf545866
Pointer e0979b89bf545866
It's worth noting that here two structs with the same content (eg: a copy), where one is a pointer and one isn't, both hash to the same value.
You can run this via:
go run example/example.go
Key features
- uses fnv 64a hashing algorithm which is fast with good distribution
- deterministic hashing for maps (which don't have any order) by sorting on the hash of the keys
Docs
http://godoc.org/github.com/davegardnerisme/deephash
Related Skills
node-connect
347.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
107.8kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
347.0kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
347.0kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
