-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
omitempty tag does not work for empty time.Time struct field when using HSet #3208
Comments
This solution makes sense to me, have you tried it? @gh73962 |
Also if you use |
This is the expected behaviour right now K guess but with go 1.24 https://www.bytesizego.com/blog/go-124-omitzero#:~:text=What%20Does%20omitzero,nil%20(nothing) Take a look at this |
I was checking the code, it seems like it doesn't respect when a struct field is nil or not, it just goes on and dereference it. This seems to be a bug for me, check following function for instance. First of all unlike other types (bool, string, ...) it doesn't consider a |
In my use case, this solution is work. If you think your approach works, I need collect more test cases. However, directly checking case reflect.Struct feels a bit rough and not very elegant. I don’t have a better solution on my end either. @SoulPancake |
@aliforever would you like to open a PR for the potential @gh73962 the proposed solution makes sense to me. |
Upon a thorough examination, the function https://github.com/golang/go/blob/go1.18/src/reflect/value.go#L1520
The appropriate solution is.
I will first submit a PR based on the solution initially proposed. |
Sure, though @gh73962 has also said will open a PR @gh73962 Will your solution fix the issue with nil pointers?
|
I haven't tried to reproduce the issue I mentioned yet. I need to reproduce it first to identify the problem before handling it @aliforever |
Issue tracker is used for reporting bugs and discussing new features. Please use
stackoverflow for supporting issues.
Expected Behavior
should be
Current Behavior
Possible Solution
https://github.com/redis/go-redis/blob/master/commands.go#L142
Steps to Reproduce
Context (Environment)
Detailed Description
omitempty tag does not work for empty time.Time struct field when using HSet
Possible Implementation
If you agree with the proposal I made in the title "Possible Solution," I can proceed to complete this PR.
The text was updated successfully, but these errors were encountered: