从redis服务器获取列表元素,从[] interface {}到[] string

I trying to connect with using redigo, redis-server is running.

I want to create a list of strings, append one string , then get all the elements from the server and print them out.

this , what I tried

package main

import (
    "fmt"
    "github.com/garyburd/redigo/redis"
)

func main() {
    c, err := redis.Dial("tcp", ":6379")
    check(err)
    defer c.Close()
    _, err = c.Do("LPUSH", "bars", "foo")
    check(err)

    n, err := redis.Values(c.Do("LRANGE", "bars", 0, 10))
    check(err)
    fmt.Println(n)
}

func check(err error) {
    if err != nil {
        panic(err)
    }
}

I get [[102 111 111]] printed instead of foo, it seems that

How can I convert []interface{} (Values return type) to []string ?

I'm not familiar with the package you're using, but the documentation suggests that using redis.Strings() instead of redis.Values() will do what you're after:

Strings is a helper that converts a multi-bulk command reply to a []string. If err is not equal to nil, then Strings returns nil, err. If one if the multi-bulk items is not a bulk value or nil, then Strings returns an error.

maybe you can try this redis client for golang:

https://github.com/xuyu/goredis

:)