developer-guy
developer-guy

Reputation: 157

Redis connection with go lang

I am getting

dial : unknown network error

when i try to connect redis in go lang like this :

var client *redis.Client

client = redis.NewClient(&redis.Options{
    Addr : "localhost:6379",
    Password:"",
    DB       : 0,
});

Why i am getting this error,please help.

Upvotes: 0

Views: 4615

Answers (1)

Mr_Pink
Mr_Pink

Reputation: 109447

You're not providing a network parameter for the Dialer:

client := redis.NewClient(&redis.Options{
    Network:  "tcp",
    Addr:     "localhost:6379",
    Password: "",
    DB:       0,
})

Or use NewTCPClient, which sets the "tcp" network parameter for you.

Upvotes: 6

Related Questions