My code with which I try to connect to REDIS SENTINEL. Since I'm new to golang wanted to clarify what's wrong with me? REDIS SENTINEL is configured and works correctly.
package main
import (
"fmt"
"github.com/go-redis/redis"
)
func main() {
rdb:=redis.NewFailoverClient(&redis.FailoverOptions(
MasterName: "mymaster",
SentinelAddrs: "XXX.XXX.XXX.XXX:26379","XXX.XXX.XXX.XXX:26379","XXX.XXX.XXX.XXX:26379",
))
rdb.Ping()
}
Run:
$ go run redis.go
**# command-line-arguments**
>./redif.go:11:12: syntax error: unexpected :, expecting comma or )**
The error says that you have used the wrong formatted string slice.
See the FailoverOption{} from "go-redis" pkg. It says the .SentinelAddrs
is of []string
type.
rdb:=redis.NewFailoverClient(&redis.FailoverOptions(
MasterName: "mymaster",
SentinelAddrs: []string{"XXX.XXX.XXX.XXX:26379","XXX.XXX.XXX.XXX:26379","XXX.XXX.XXX.XXX:26379"},
))