session 存储时出现:runtime error: invalid memory address or nil pointer dereference

qiaoshuai951123 · · 514 次点击 · 开始浏览    置顶

![WX20220517-190539@2x.png](https://static.golangjob.cn/220517/f50f65adc06aea2eceb5f6d750102360.png) ```go runtime error: invalid memory address or nil pointer dereference /opt/homebrew/Cellar/go/1.18/libexec/src/runtime/panic.go:220 (0x1042418fb) panicmem: panic(memoryError) /opt/homebrew/Cellar/go/1.18/libexec/src/runtime/signal_unix.go:818 (0x10425958b) sigpanic: panicmem() /Users/handsomejob/go项目/goshop/utils/captcha/captcha.go:23 (0x10494f124) Captcha: session.Values["captchaCode"] = captchaId /Users/handsomejob/go项目/goshop/app/v1/route/route.go:22 (0x10495156f) Routers.func1: captcha.Captcha(ctx) /Users/handsomejob/go/pkg/mod/github.com/gin-gonic/gin@v1.7.7/context.go:168 (0x10492007f) (*Context).Next: c.handlers[c.index](c) /Users/handsomejob/go/pkg/mod/github.com/gin-gonic/gin@v1.7.7/recovery.go:99 (0x104920060) CustomRecoveryWithWriter.func1: c.Next() /Users/handsomejob/go/pkg/mod/github.com/gin-gonic/gin@v1.7.7/context.go:168 (0x10491f32f) (*Context).Next: c.handlers[c.index](c) /Users/handsomejob/go/pkg/mod/github.com/gin-gonic/gin@v1.7.7/logger.go:241 (0x10491f30c) LoggerWithConfig.func1: c.Next() /Users/handsomejob/go/pkg/mod/github.com/gin-gonic/gin@v1.7.7/context.go:168 (0x10491e497) (*Context).Next: c.handlers[c.index](c) /Users/handsomejob/go/pkg/mod/github.com/gin-gonic/gin@v1.7.7/gin.go:555 (0x10491e16c) (*Engine).handleHTTPRequest: c.Next() /Users/handsomejob/go/pkg/mod/github.com/gin-gonic/gin@v1.7.7/gin.go:511 (0x10491dd83) (*Engine).ServeHTTP: engine.handleHTTPRequest(c) /opt/homebrew/Cellar/go/1.18/libexec/src/net/http/server.go:2916 (0x1044fedfb) serverHandler.ServeHTTP: handler.ServeHTTP(rw, req) /opt/homebrew/Cellar/go/1.18/libexec/src/net/http/server.go:1966 (0x1044fa51b) (*conn).serve: serverHandler{c.server}.ServeHTTP(w, w.req) /opt/homebrew/Cellar/go/1.18/libexec/src/runtime/asm_arm64.s:1259 (0x1042729e3) goexit: MOVD R0, R0 // NOP ```

有疑问加站长微信联系(非本文作者)

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

514 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传