Skip to content

Commit 07e15d2

Browse files
committed
fix: tags for structToMap "json" -> "key"
1 parent 4ce9046 commit 07e15d2

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

commands.go

Lines changed: 5 additions & 2 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("json")
94+
tag := v.Field(i).Tag.Get("key")
9595

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

0 commit comments

Comments
 (0)