-
Notifications
You must be signed in to change notification settings - Fork 2.4k
HMGet
can't scan type time.Time
#2161
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
Comments
Ah, this library also has this feature! Map the data in the hash table to the structure! |
@edoger |
@ntswamp I never knew there was such a feature that we implemented a similar one ourselves! |
Any update on this issue? |
I also have issues with this. Reading the data from redis-cli, the date is correct. Btw, according to |
I followed the author's update on
Does the author will add functions similar to func (t *TimeValue) RedisValue() string {
return t.Time.String()
} |
If type MyStruct struct {
// call:time.UnmarshalText(data) , parseRFC3339
Time time.Time `redis:"time"`
} Custom time format: type TimeValue struct {
time.Time
}
func (t *TimeValue) ScanRedis(s string) (err error) {
t.Time, err = time.Parse(time.Date, s)
return
}
type data struct {
Key1 string `redis:"key1"`
Key2 int `redis:"key2"`
Time TimeValue `redis:"time"`
}
var d data
res := client.MGet(ctx, "key1", "key2", "time")
res.Scan(&d) |
This can be either resolved as @monkey92t suggested or @michelemendel, you can use newer version. This should be supported right now. |
Uh oh!
There was an error while loading. Please reload this page.
Version: github.com/go-redis/redis/v8 v8.11.4
Hi, I found the test case(https://github.com/go-redis/redis/blob/e061db8c13fd6b5e007d73370873026e360719de/redis_test.go#L274),`time.Time` can be scanned to object. But it's wrong when I used it in

hmget(...).scan(&u)
The text was updated successfully, but these errors were encountered: