I am using "garyburd/redigo/redis" in my goLang application and trying to make subscription to multiple channels using pubSubConn.Subscribe()
Passing values like pubSubConn.Subscribe("chn1", "chn2")
works and creates subscription to two channels but I don't know how to pass n channels in this function. I have tried passing slice of interface, but it converts it to string
var anything []interface{}
var stringList []string
stringList = append(stringList, "chn1")
stringList = append(stringList, "chn2")
for _, val := range stringList {
anything = append(anything, val)
}
But output is subscription to one channel "[chn1 chn2]"
Please help.
Try the code below
var stringList []string
stringList = append(stringList, "chn1")
stringList = append(stringList, "chn2")
pubSubConn.Subscribe(stringList...)
more https://golang.org/ref/spec#Passing_arguments_to_..._parameters