golang mysql gin 报错

2ob06q8z
  • 5
新手上路,请多包涵
2021/10/22 09:50:49 [Recovery] 2021/10/22 - 09:50:49 panic recovered:
runtime error: invalid memory address or nil pointer dereference
/snap/go/8489/src/runtime/panic.go:221 (0x44a446)
        panicmem: panic(memoryError)
/snap/go/8489/src/runtime/signal_unix.go:735 (0x44a416)
        sigpanic: panicmem()
/snap/go/8489/src/database/sql/sql.go:2578 (0x4f30c2)
        (*Stmt).ExecContext: s.closemu.RLock()
/snap/go/8489/src/database/sql/sql.go:2610 (0x840fd4)
        (*Stmt).Exec: return s.ExecContext(context.Background(), args...)
/root/onlineUsers/hello.go:63 (0x840f36)
        main.func1: _, err = stmt.Exec(req.IdCode, c.Request.RemoteAddr)
/root/go/pkg/mod/github.com/gin-gonic/gin@v1.7.4/context.go:165 (0x81e7e1)
        (*Context).Next: c.handlers[c.index](c)
/root/go/pkg/mod/github.com/gin-gonic/gin@v1.7.4/recovery.go:99 (0x81e7cc)
        CustomRecoveryWithWriter.func1: c.Next()
/root/go/pkg/mod/github.com/gin-gonic/gin@v1.7.4/context.go:165 (0x81d69d)
        (*Context).Next: c.handlers[c.index](c)
/root/go/pkg/mod/github.com/gin-gonic/gin@v1.7.4/gin.go:489 (0x81d325)
        (*Engine).handleHTTPRequest: c.Next()
/root/go/pkg/mod/github.com/gin-gonic/gin@v1.7.4/gin.go:445 (0x81ce84)
        (*Engine).ServeHTTP: engine.handleHTTPRequest(c)
/snap/go/8489/src/net/http/server.go:2878 (0x674e1a)
        serverHandler.ServeHTTP: handler.ServeHTTP(rw, req)
/snap/go/8489/src/net/http/server.go:1929 (0x6704c7)
        (*conn).serve: serverHandler{c.server}.ServeHTTP(w, w.req)
/snap/go/8489/src/runtime/asm_amd64.s:1581 (0x464a60)
        goexit: BYTE    $0x90   // NOP

请问一下,这个是怎么回事,刚开始运行的时候没问题,过了一段时间出的问题,用了mysql和gin,会不会是因为我用的是mysql驱动里面的stmt.Exec没用stmt.ExecContext,所以并发出错

回复
阅读 316
1 个回答

prepare 拿到的stmt,关闭了还在用?

你知道吗?

宣传栏