I am trying to rpush multiple elements to a redis key. Currently using a redis pool connection using https://github.com/gomodule/redigo.
If I try to put an array into rpush , a string with the array concatenated is pushed. How can I push individual elements instead
conn := Pool.Get() // A redigo redis pool
arr := []string{"a", "b", "c", "d"}
conn.Do("RPUSH","TEST","x","y") // This works
conn.Do("RPUSH", "TEST", arr) //This does not work
I don't have the library but from what I saw on their documentation, I guess that this should work:
...
is a parameter operator that unpacks the elements of your slice and passes as them separate arguments to a variadic function, which would be the same as this:More information can be found on variadic function in go in this very complete article