github.com/seeker-insurance/kit@v0.0.13/db/redis/redis.go (about) 1 package redis 2 3 import ( 4 "github.com/seeker-insurance/kit/config" 5 "github.com/seeker-insurance/kit/log" 6 r "github.com/go-redis/redis" 7 "github.com/spf13/cobra" 8 ) 9 10 var Client *r.Client 11 12 func init() { 13 cobra.OnInitialize(connectDB) 14 } 15 16 func connectDB() { 17 url := config.RequiredString("redis_url") 18 opts, err := r.ParseURL(url) 19 log.Check(err) 20 Client = r.NewClient(opts) 21 }