-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Allow struct on HSet #1960
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow struct on HSet #1960
Conversation
884fc70 to
4ce9046
Compare
|
I want to use this feature |
7d6f91b to
6fd61e8
Compare
|
Should we use the "json" tag? I feel like it's better handled by the person who needs it. func structToMap() {
....
}
client.Hset(ctx, "key", structToMap(items)) |
Thank you for your reply. I felt that the experience of using the library was reduced because the person who wanted it had to make it from the outside, and I thought it would be ideal to solve it internally. It doesn't have to be a "json" tag, but I think we need a tag for our hash keys. |
|
We should think more, like tag="" or tag="-", or for types like: type Demo struct {
Pers []int
Ptr *struct
Map map[string]*struct
...
} |
|
I modified the tag name. The example has also been modified. But if you don't think it's necessary, you can close the PR! |
|
I was wondering why this does not exist yet. Thanks for the code - I guess you should maybe use the tag |
|
Sorry i'm just too late.. I accepted your feedback and I just changed serialize key "key" to "redis" |
… test Signed-off-by: monkey92t <[email protected]>
|
I added support for structure types in the I added the description of using the struct type in the API comments, and added the test function. We should note that for complex field types of structures, the encoding.BinaryMarshaler interface should be implemented. Synchronized with v9. |
Signed-off-by: monkey92t <[email protected]>
Each time, struct had to be converted to map and put it in.
So I thought it would be better to embed it inside the function.