老师您好,我想问下为什么运行您的代码会报错啊,mysql我也按照视频里配置好了,就是访问8080/product/all的时候

来源:5-13 商品管理功能Controller&View开发 (中)

qq_慕姐5368399

2022-06-20

[HTTP Server] http: panic serving 127.0.0.1:13635: runtime error: invalid memory address or nil pointer dereference
goroutine 13 [running]:
net/http.(*conn).serve.func1(0xc0000d0000)
	C:/Program Files/Go/src/net/http/server.go:1824 +0x153
panic(0x8c0d00, 0xec5030)
	C:/Program Files/Go/src/runtime/panic.go:971 +0x49a
imooc-product/backend/web/controllers.(*ProductController).GetAll(0xc000632320, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
	C:/go/src/imooc-product/backend/web/controllers/product_controller.go:18 +0x5e
reflect.Value.call(0x906860, 0xc000632320, 0x613, 0x98dc4c, 0x4, 0xf23640, 0x0, 0x0, 0x6, 0xc00058d880, ...)
	C:/Program Files/Go/src/reflect/value.go:476 +0x907
reflect.Value.Call(0x906860, 0xc000632320, 0x613, 0xf23640, 0x0, 0x0, 0x613, 0xe, 0x0)
	C:/Program Files/Go/src/reflect/value.go:337 +0xc5
github.com/kataras/iris/v12/mvc.(*ControllerActivator).handlerOf.func2(0xabc888, 0xc0005ae1b0)
	C:/go/pkg/mod/github.com/kataras/iris/v12@v12.1.8/mvc/controller.go:497 +0x3cb
github.com/kataras/iris/v12/context.Do(0xabc888, 0xc0005ae1b0, 0xc000590070, 0x1, 0x1)
	C:/go/pkg/mod/github.com/kataras/iris/v12@v12.1.8/context/context.go:1030 +0x88
github.com/kataras/iris/v12/context.(*context).Do(0xc0005ae1b0, 0xc000590070, 0x1, 0x1)
	C:/go/pkg/mod/github.com/kataras/iris/v12@v12.1.8/context/context.go:1217 +0x5c
github.com/kataras/iris/v12/core/router.(*routerHandler).HandleRequest(0xc0000629e0, 0xabc888, 0xc0005ae1b0)
	C:/go/pkg/mod/github.com/kataras/iris/v12@v12.1.8/core/router/handler.go:250 +0x562
github.com/kataras/iris/v12/core/router.(*Router).BuildRouter.func1(0xaa9360, 0xc0005aa0e0, 0xc00055c000)
	C:/go/pkg/mod/github.com/kataras/iris/v12@v12.1.8/core/router/router.go:135 +0x9a
github.com/kataras/iris/v12/core/router.(*Router).ServeHTTP(0xc000095b30, 0xaa9360, 0xc0005aa0e0, 0xc00055c000)
	C:/go/pkg/mod/github.com/kataras/iris/v12@v12.1.8/core/router/router.go:227 +0x4f
net/http.serverHandler.ServeHTTP(0xc0005aa000, 0xaa9360, 0xc0005aa0e0, 0xc00055c000)
	C:/Program Files/Go/src/net/http/server.go:2887 +0xaa
net/http.(*conn).serve(0xc0000d0000, 0xaab820, 0xc0001ec200)
	C:/Program Files/Go/src/net/http/server.go:1952 +0x8cd
created by net/http.(*Server).Serve
	C:/Program Files/Go/src/net/http/server.go:3013 +0x3b8

这个是报错信息,然后我是按照您的代码运行的,跑不出来。

写回答

1回答

Cap

2022-07-15

过去到信息应该是空的报错了

0
1
Cap
过去=》获取
2022-07-15
共1条回复

全流程开发 GO实战电商网站高并发秒杀系统

运用架构设计与系统化思维,从容应对不同流量等级的“秒杀”场景

1462 学习 · 443 问题

查看课程