Skip to content

runtime error: invalid memory address or nil pointer dereference #10

Closed
@OmidHaqi

Description

@OmidHaqi

2025/05/04 14:44:53 [Recovery] 2025/05/04 - 14:44:53 panic recovered:
POST /api/v1/users/send-otp HTTP/1.1
Host: localhost:5005
Accept: application/json
Accept-Encoding: gzip, deflate, br, zstd
Accept-Language: en-US,en;q=0.9,fa;q=0.8
Connection: keep-alive
Content-Length: 35
Content-Type: application/json
Cookie: grafana_session=b0d49710a95db06dcebda505b8c7d1f8; grafana_session_expiry=1745528600; pma_lang=en; pmaUser-1=Ya800dLjIBKszBM4oBXWHBI1ViEQAJS1gGqe8r7eTAx5SNKo%2FVyufYHEBrc%3D
Origin: http://localhost:5005
Referer: http://localhost:5005/swagger/index.html
Sec-Ch-Ua: "Chromium";v="136", "Google Chrome";v="136", "Not.A/Brand";v="99"
Sec-Ch-Ua-Mobile: ?0
Sec-Ch-Ua-Platform: "Linux"
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36


runtime error: invalid memory address or nil pointer dereference
/usr/local/go/src/runtime/panic.go:262 (0x474298)
        panicmem: panic(memoryError)
/usr/local/go/src/runtime/signal_unix.go:900 (0x474268)
        sigpanic: panicmem()
/home/umut/Downloads/golang-clean-web-api-master/src/usecase/otp_usecase.go:49 (0xaff9a5)
        (*OtpUsecase).SetOtp: res, err := cache.Get[otpDto](s.redisClient, key)
/home/umut/Downloads/golang-clean-web-api-master/src/usecase/otp_usecase.go:35 (0xaff87e)
        (*OtpUsecase).SendOtp: err := u.SetOtp(mobileNumber, otp)
/home/umut/Downloads/golang-clean-web-api-master/src/api/handler/user.go:130 (0xdcc00a)
        (*UsersHandler).SendOtp: err = h.otpUsecase.SendOtp(req.MobileNumber)
/home/umut/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 (0xbdaee4)
        (*Context).Next: c.handlers[c.index](c)
/home/umut/Downloads/golang-clean-web-api-master/src/api/middleware/otp_limiter.go:24 (0xbdaddd)
        OtpLimiter.func1: c.Next()
/home/umut/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 (0xbda0f0)
        (*Context).Next: c.handlers[c.index](c)
/home/umut/Downloads/golang-clean-web-api-master/src/api/middleware/limiter.go:20 (0xbda01d)
        LimitByRequest.func1: c.Next()
/home/umut/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 (0x96d7ae)
        (*Context).Next: c.handlers[c.index](c)
/home/umut/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/recovery.go:102 (0x96d79b)
        CustomRecoveryWithWriter.func1: c.Next()
/home/umut/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 (0x96c8fc)
        (*Context).Next: c.handlers[c.index](c)
/home/umut/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/logger.go:240 (0x96c8e3)
        LoggerWithConfig.func1: c.Next()
/home/umut/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 (0x960cca)
        (*Context).Next: c.handlers[c.index](c)
/home/umut/Downloads/golang-clean-web-api-master/src/api/middleware/prometheus.go:17 (0xebb834)
        InitServer.Prometheus.func2: c.Next()
/home/umut/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 (0x960cca)
        (*Context).Next: c.handlers[c.index](c)
/home/umut/Downloads/golang-clean-web-api-master/src/api/middleware/cors.go:22 (0xeb6e85)
        InitServer.Cors.func1: c.Next()
/home/umut/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 (0x960cca)
        (*Context).Next: c.handlers[c.index](c)
/home/umut/Downloads/golang-clean-web-api-master/src/api/middleware/logger.go:49 (0xbda5a6)
        DefaultStructuredLogger.structuredLogger.func1: c.Next()
/home/umut/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 (0x96bded)
        (*Context).Next: c.handlers[c.index](c)
/home/umut/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/gin.go:620 (0x96ba84)
        (*Engine).handleHTTPRequest: c.Next()
/home/umut/go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/gin.go:576 (0x96b5d1)
        (*Engine).ServeHTTP: engine.handleHTTPRequest(c)
/usr/local/go/src/net/http/server.go:3210 (0x714c4d)
        serverHandler.ServeHTTP: handler.ServeHTTP(rw, req)
/usr/local/go/src/net/http/server.go:2092 (0x704ecf)
        (*conn).serve: serverHandler{c.server}.ServeHTTP(w, w.req)
/usr/local/go/src/runtime/asm_amd64.s:1700 (0x47a120)
        goexit: BYTE    $0x90   // NOP

[GIN] 2025/05/04 - 14:44:53 | 500 |    1.815466ms |             ::1 | POST     "/api/v1/users/send-otp"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions