From 441b4b15a884638ab8d4362ce8b42e1e9db80216 Mon Sep 17 00:00:00 2001 From: xgopilot Date: Tue, 14 Oct 2025 07:11:17 +0000 Subject: [PATCH] test: add hash/maphash demo test case Add test case in _demo/go/maphash to verify hash/maphash functionality with the new runtime.rand and runtime.memhash support. Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: luoliwoshang Co-authored-by: xgopilot --- _demo/go/maphash/maphash.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 _demo/go/maphash/maphash.go diff --git a/_demo/go/maphash/maphash.go b/_demo/go/maphash/maphash.go new file mode 100644 index 00000000..44524b04 --- /dev/null +++ b/_demo/go/maphash/maphash.go @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "hash/maphash" +) + +func main() { + var h maphash.Hash + h.WriteString("hello") + fmt.Printf("0x%x\n", h.Sum64()) + + h.Reset() + h.WriteString("world") + fmt.Printf("0x%x\n", h.Sum64()) + + h.Reset() + h.WriteString("test") + v1 := h.Sum64() + + h.Reset() + h.WriteString("test") + v2 := h.Sum64() + + fmt.Printf("0x%x == 0x%x\n", v1, v2) +}