为了账号安全,请及时绑定邮箱和手机立即绑定

Redigo:尝试连接到池时无效的内存地址或零指针取消引用

Redigo:尝试连接到池时无效的内存地址或零指针取消引用

Go
千巷猫影 2021-10-25 20:20:46
Redis 连接.....!恐慌:运行时错误:无效的内存地址或零指针取消引用[信号0xb代码=0x1 addr=0x28 pc=0x40154b]goroutine 1 [运行]:runtime.panic(0x52c6e0, 0x6b6348)/usr/lib/go/src/pkg/运行时/panic.c:266 +0xb6main.func·001(0xc21005102c, 0x0, 0x4bcd4c, 0x1)/home/vinay10949/redischeck/redischeck.go:21 +0x10bgithub.com/garyburd.(*Preigo/ ).get(0xc210051000, 0x0,0xc2100378f0, 0x42dbdf, 0x7fbe9c177070) /usr/lib/go/src/pkg/github.com/garyburd/redigo/redis/pool.go:250+0x3a redis.(*Pool).Get(0xc210051000, 0x1, 0x1) > /usr/lib/go/src/pkg/github.com/garyburd/redigo/redis/pool.go:150+0x27 main.main() /家/vinay10949/redischeck/redischeck.go:29 +0x13epackage mainimport (    "flag"    "fmt"    "github.com/garyburd/redigo/redis"    //"reflect")var (    redisAddress   = flag.String("10.12.2.121", "10.12.2.121:6379", "Address to the Redis server")    maxConnections = flag.Int("max-connections", 10, "Max connections to Redis"))func main() {    //Redis Connection    redisPool := redis.NewPool(func() (redis.Conn, error) {        con, err := redis.Dial("tcp", *redisAddress)        con.Do("SELECT", 1)        if err != nil {            return nil, err        }        return con, err    }, *maxConnections)    fmt.Println("Redis Connecting...!")    con := redisPool.Get()    status, errStatus := con.Do("SET", "Name", "BookMyShow")    if errStatus != nil {        fmt.Println(errStatus)    } else {        fmt.Println("Redis Connected")    }    statusInsertion, _ := redis.String(status, errStatus)    fmt.Println("Status of Insertion :" + statusInsertion)    value, _ := redis.String(con.Do("GET", "Name"))    fmt.Println("Value Retrieved : " + value)}
查看完整描述

2 回答

  • 2 回答
  • 0 关注
  • 220 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信