Skip to content

Commit 913936b

Browse files
committed
fix: change serialize key "key" to "redis"
1 parent 1fdcbf8 commit 913936b

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

commands.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func structToMap(items interface{}) map[string]interface{} {
9191
v = v.Elem()
9292
}
9393
for i := 0; i < v.NumField(); i++ {
94-
tag := v.Field(i).Tag.Get("key")
94+
tag := v.Field(i).Tag.Get("redis")
9595

9696
if tag != "" && v.Field(i).Type.Kind() != reflect.Struct {
9797
field := reflectValue.Field(i).Interface()
@@ -1286,8 +1286,8 @@ func (c cmdable) HMGet(ctx context.Context, key string, fields ...string) *Slice
12861286
// - HSet("myhash", []string{"key1", "value1", "key2", "value2"})
12871287
// - HSet("myhash", map[string]interface{}{"key1": "value1", "key2": "value2"})
12881288
//
1289-
// Playing struct With "key" tag
1290-
// - type MyHash struct { Key1 string `key:"key1"`; Key2 int `key:"key2"` }
1289+
// Playing struct With "redis" tag
1290+
// - type MyHash struct { Key1 string `redis:"key1"`; Key2 int `redis:"key2"` }
12911291
// - HSet("myhash", MyHash{"value1", "value2"})
12921292
//
12931293
// Note that it requires Redis v4 for multiple field/value pairs support.

example_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,10 @@ func ExampleClient_SetEX() {
198198
}
199199

200200
func ExampleClient_HSet() {
201-
// Set "key" tag for hash key
201+
// Set "redis" tag for hash key
202202
type ExampleUser struct {
203-
Name string `key:"name"`
204-
Age int `key:"age"`
203+
Name string `redis:"name"`
204+
Age int `redis:"age"`
205205
}
206206

207207
items := ExampleUser{"jane", 22}

0 commit comments

Comments
 (0)