看了教程都是些简单的例子,结果写个程序一出错连哪一行出错都没说,也不知道咋办。。。
runtime error: invalid memory address or nil pointer dereference
/home/keane/app/go/src/runtime/panic.go:199 (0x443fcb)
panicmem: panic(memoryError)
/home/keane/app/go/src/runtime/signal_unix.go:394 (0x443e08)
sigpanic: panicmem()
/home/keane/go/pkg/mod/github.com/jinzhu/gorm@v1.9.16/main.go:853 (0x969875)
(*DB).clone: dialect: newDialect(s.dialect.GetName(), s.db),
/home/keane/go/pkg/mod/github.com/jinzhu/gorm@v1.9.16/main.go:204 (0x96291e)
(*DB).NewScope: dbClone := s.clone()
/home/keane/go/pkg/mod/github.com/jinzhu/gorm@v1.9.16/main.go:354 (0x96503b)
(*DB).Find: return s.NewScope(out).inlineCondition(where...).callCallbacks(s.parent.callbacks.queries).db
/home/keane/GolandProjects/poblog/services/postService.go:168 (0x99722c)
(*PostService).List: db.Find(&posts)
/home/keane/GolandProjects/poblog/controllers/postController.go:11 (0x9973ac)
ListPost: _,_=postService.List()
/home/keane/go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/context.go:161 (0x8f2d1a)
(*Context).Next: c.handlers[c.index](c)
/home/keane/GolandProjects/poblog/middlewares/corsMiddleware.go:23 (0x99747c)
Cors.func1: c.Next()
/home/keane/go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/context.go:161 (0x8f2d1a)
(*Context).Next: c.handlers[c.index](c)
/home/keane/go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/recovery.go:83 (0x906b43)
RecoveryWithWriter.func1: c.Next()
/home/keane/go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/context.go:161 (0x8f2d1a)
(*Context).Next: c.handlers[c.index](c)
/home/keane/go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/logger.go:241 (0x905c70)
LoggerWithConfig.func1: c.Next()
/home/keane/go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/context.go:161 (0x8f2d1a)
(*Context).Next: c.handlers[c.index](c)
/home/keane/go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/gin.go:409 (0x8fcf8c)
(*Engine).handleHTTPRequest: c.Next()
/home/keane/go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/gin.go:367 (0x8fc68d)
(*Engine).ServeHTTP: engine.handleHTTPRequest(c)
/home/keane/app/go/src/net/http/server.go:2802 (0x6cb8a3)
serverHandler.ServeHTTP: handler.ServeHTTP(rw, req)
/home/keane/app/go/src/net/http/server.go:1890 (0x6c7144)
(*conn).serve: serverHandler{c.server}.ServeHTTP(w, w.req)
/home/keane/app/go/src/runtime/asm_amd64.s:1357 (0x45c0c0)
goexit: BYTE $0x90 // NOP
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.