You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
res := rdb.HGetAll(ctx, "map")
if res.Err() != nil {
panic(err)
}
type data struct {
Name string `redis:"name"`
Count int `redis:"count"`
Correct bool `redis:"correct"`
}
// Scan the results into the struct.
var d data
if err := res.Scan(&d); err != nil {
panic(err)
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
In this code you get the idea it's possible to convert the output
map
fromrdb.HGetAll()
to a structBut when you try to compile it
undefined (type map[string]string has no field or method Scan)
go-redis/example_test.go
Line 281 in f8cbf48
Beta Was this translation helpful? Give feedback.
All reactions