通话中的参数过多

I'm trying to load db data to redis cluster using mysql2redis.

When i try the accepted solution, i.e.,

} else if e.Command == "HMSET" {
    // Build up a string slice to hold the key value pairs
    args := make([]string, 0, len(e.MapData) * 2)
    for k, v := range e.MapData {
        args = append(args, k, v)
    }
    _,err := redis.StringMap(client.Do("HMSET", e.Key, args...))
    checkErr(err, "hmset error:")
}

I get following exception,

too many arguments in call to client.Do
    have (string, string, []string...)
    want (string, ...interface {})

I'm a newbie when it comes to Go. So can the Go veterans take a look at this and suggest a solution?

In Go you can use a slice for a variadic parameter. However, the slice must contain all the parameters you need to pass to the function. You cannot expand a slice and pass additional parameters as well.

Hence your code should be something like:

args := make([]interface{}, 0, len(e.MapData) * 2 + 1)
args = append(args, e.Key)
for k, v := range e.MapData {
    args = append(args, k, v)
}
_,err := redis.StringMap(client.Do("HMSET", args...))