mirror of https://github.com/go-redis/redis.git
fix: change serialize key "key" to "redis"
This commit is contained in:
parent
1fdcbf86bb
commit
913936b4cd
|
@ -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.
|
||||
|
|
|
@ -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}
|
||||
|
|
Loading…
Reference in New Issue