From f5474247c2edfce064f6a78f6f86f86e9d9bdb80 Mon Sep 17 00:00:00 2001 From: Rueian Date: Mon, 4 Dec 2023 23:52:19 +0800 Subject: [PATCH] feat: remove unsafe.Slice in om to support go1.18 --- om/conv.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/om/conv.go b/om/conv.go index 0fbbb7c7..c8228ac7 100644 --- a/om/conv.go +++ b/om/conv.go @@ -3,10 +3,9 @@ package om import ( "encoding/json" "fmt" + "github.com/redis/rueidis" "reflect" "strconv" - - "github.com/redis/rueidis" ) func newHashConvFactory(t reflect.Type, schema schema) *hashConvFactory { @@ -68,7 +67,7 @@ func (r hashConv) FromHash(fields map[string]string) error { continue } if f.conv.StringToValue == nil { - if err := json.Unmarshal(unsafe.Slice(unsafe.StringData(v), len(v)), r.entity.Field(f.idx).Addr().Interface()); err != nil { + if err := json.Unmarshal([]byte(v), r.entity.Field(f.idx).Addr().Interface()); err != nil { return err } } else {