From 6dccae260b53fe3a1adef59a39a4a35760f2f241 Mon Sep 17 00:00:00 2001 From: qiulaidongfeng <2645477756@qq.com> Date: Tue, 24 Sep 2024 21:09:26 +0800 Subject: [PATCH] new Change-Id: Ib9092286e351cc7f488c414222478318a2ffbc76 --- src/hash/maphash/maphash.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/hash/maphash/maphash.go b/src/hash/maphash/maphash.go index 76127a1894..6077a1033e 100644 --- a/src/hash/maphash/maphash.go +++ b/src/hash/maphash/maphash.go @@ -339,8 +339,14 @@ func appendT(h *Hash, v reflect.Value) { h.WriteString(v.String()) return case reflect.Struct: + var buf [8]byte for i := range v.NumField() { f := v.Field(i) + byteorder.LePutUint64(buf[:], uint64(i)) + // do not want to hash to the same value, + // struct{a,b string}{"foo",""} and + // struct{a,b string}{"","foo"}. + h.Write(buf[:]) appendT(h, f) } return