我是redigo,要从Go连接到redis数据库。如何将类型转换[]interface {}{[]byte{} []byte{}}为一组字符串?在这种情况下,我想得到两个字符串Hello和World。package mainimport ( "fmt" "github.com/garyburd/redigo/redis")func main() { c, err := redis.Dial("tcp", ":6379") defer c.Close() if err != nil { fmt.Println(err) } c.Send("SADD", "myset", "Hello") c.Send("SADD", "myset", "World") c.Flush() c.Receive() c.Receive() err = c.Send("SMEMBERS", "myset") if err != nil { fmt.Println(err) } c.Flush() // both give the same return value!?!? // reply, err := c.Receive() reply, err := redis.MultiBulk(c.Receive()) if err != nil { fmt.Println(err) } fmt.Printf("%#v\n", reply) // $ go run main.go // []interface {}{[]byte{0x57, 0x6f, 0x72, 0x6c, 0x64}, []byte{0x48, 0x65, 0x6c, 0x6c, 0x6f}} // How do I get 'Hello' and 'World' from this data?}
2 回答
- 2 回答
- 0 关注
- 227 浏览
添加回答
举报
0/150
提交
取消