From 913936b4cd9ae131e4671d0960bf1f9e46e6b171 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A0=95=EB=B3=B4=EA=B5=90?= Date: Thu, 19 Jan 2023 13:00:04 +0900 Subject: [PATCH] fix: change serialize key "key" to "redis" --- commands.go | 6 +++--- example_test.go | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/commands.go b/commands.go index ff096c6e..2947d0ff 100644 --- a/commands.go +++ b/commands.go @@ -91,7 +91,7 @@ func structToMap(items interface{}) map[string]interface{} { v = v.Elem() } for i := 0; i < v.NumField(); i++ { - tag := v.Field(i).Tag.Get("key") + tag := v.Field(i).Tag.Get("redis") if tag != "" && v.Field(i).Type.Kind() != reflect.Struct { field := reflectValue.Field(i).Interface() @@ -1286,8 +1286,8 @@ func (c cmdable) HMGet(ctx context.Context, key string, fields ...string) *Slice // - HSet("myhash", []string{"key1", "value1", "key2", "value2"}) // - HSet("myhash", map[string]interface{}{"key1": "value1", "key2": "value2"}) // -// Playing struct With "key" tag -// - type MyHash struct { Key1 string `key:"key1"`; Key2 int `key:"key2"` } +// Playing struct With "redis" tag +// - type MyHash struct { Key1 string `redis:"key1"`; Key2 int `redis:"key2"` } // - HSet("myhash", MyHash{"value1", "value2"}) // // Note that it requires Redis v4 for multiple field/value pairs support. diff --git a/example_test.go b/example_test.go index 8b32e79e..0e602810 100644 --- a/example_test.go +++ b/example_test.go @@ -198,10 +198,10 @@ func ExampleClient_SetEX() { } func ExampleClient_HSet() { - // Set "key" tag for hash key + // Set "redis" tag for hash key type ExampleUser struct { - Name string `key:"name"` - Age int `key:"age"` + Name string `redis:"name"` + Age int `redis:"age"` } items := ExampleUser{"jane", 22}