Created
October 28, 2014 09:36
-
-
Save vireshas/d7fbe8194bf56f541200 to your computer and use it in GitHub Desktop.
hgetall from go using redigo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
values, err := redis.String(c.Do("HGETALL", queue_id, "result")) | |
if err != nil { | |
fmt.Println("HGETALL", err) | |
} | |
for i := 0; i < len(values); i += 2 { | |
key, _ := redis.String(values[i], nil) | |
value, _ := redis.String(values[i+1], nil) | |
fmt.Println(" %s: %s", key, value) | |
} | |
OR | |
type RQJob struct { | |
created_at string | |
result string | |
ended_at string | |
data string | |
status string | |
} | |
var rqjob RQJob | |
if err := redis.ScanStruct(values, &rqjob); err != nil { | |
fmt.Println(err) | |
} | |
fmt.Println("rqjob result", rqjob.result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ScanStruct can only use exported (capitalized) fields, so this will not work. You probably want something like
Created_at string
redis:"created_at"``