Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

执行./hello -syncdb表创建成功,浏览器访问报错:runtime error: invalid memory address or nil pointer dereference #68

Open
AlwaysKO opened this issue Sep 21, 2018 · 2 comments

Comments

@AlwaysKO
Copy link

按照文档步骤(之前是没有加admin.conf中的配置,导致报错。后来看到评论有说就表创建成功了),最后运行时也没有报错,访问时就报错了:
2018/09/21 15:39:24 INFO ▶ 0001 Using 'beegoAdminTest' as 'appname'
2018/09/21 15:39:24 INFO ▶ 0002 Initializing watcher...
2018/09/21 15:39:28 SUCCESS ▶ 0003 Built Successfully!
2018/09/21 15:39:28 INFO ▶ 0004 Restarting 'beegoAdminTest.exe'...
2018/09/21 15:39:28 SUCCESS ▶ 0005 './beegoAdminTest.exe' is running...
Starting....
Start ok
2018/09/21 15:39:30.365 [I] [asm_amd64.s:2337] http server Running on http://:8 080
2018/09/21 15:39:33.666 [C] [asm_amd64.s:509] the request url is /
2018/09/21 15:39:33.666 [C] [asm_amd64.s:509] Handler crashed with error runtim e error: invalid memory address or nil pointer dereference
2018/09/21 15:39:33.666 [C] [asm_amd64.s:509] C:/Go/src/runtime/asm_amd64.s:509
2018/09/21 15:39:33.666 [C] [asm_amd64.s:509] C:/Go/src/runtime/panic.go:491
2018/09/21 15:39:33.666 [C] [asm_amd64.s:509] C:/Go/src/runtime/panic.go:63
2018/09/21 15:39:33.666 [C] [asm_amd64.s:509] C:/Go/src/runtime/signal_windows. go:161
2018/09/21 15:39:33.666 [C] [asm_amd64.s:509] D:/LNMP/gowww/src/github.com/asta xie/beego/controller.go:610
2018/09/21 15:39:33.666 [C] [asm_amd64.s:509] D:/LNMP/gowww/src/github.com/beeg o/admin/src/rbac/public.go:30
2018/09/21 15:39:33.666 [C] [asm_amd64.s:509] C:/Go/src/runtime/asm_amd64.s:509
2018/09/21 15:39:33.666 [C] [asm_amd64.s:509] C:/Go/src/reflect/value.go:434
2018/09/21 15:39:33.666 [C] [asm_amd64.s:509] C:/Go/src/reflect/value.go:302
2018/09/21 15:39:33.666 [C] [asm_amd64.s:509] D:/LNMP/gowww/src/github.com/asta xie/beego/router.go:847
2018/09/21 15:39:33.666 [C] [asm_amd64.s:509] C:/Go/src/net/http/server.go:2619
2018/09/21 15:39:33.666 [C] [asm_amd64.s:509] C:/Go/src/net/http/server.go:1801
2018/09/21 15:39:33.666 [C] [asm_amd64.s:509] C:/Go/src/runtime/asm_amd64.s:233 7
2018/09/21 15:39:33.666 [server.go:2846] [HTTP] http: multiple response.WriteHe ader calls

有人遇到过这个问题吗

@AlwaysKO
Copy link
Author

我看到好多问题都没有人回答,我已经找到问题了,我来自问自答吧。
解决办法:
在main入口函数中添加:beego.BConfig.WebConfig.Session.SessionOn = true,
或者在配置文件中添加:sessionon = true

@Kylelkh
Copy link

Kylelkh commented Mar 16, 2019

这个错误是由于session没有设置,beego默认的session是没有打开的,这个时候我们需要在项目运行之初,将session打开。
在main.go中的main函数中添加如下代码
beego.BConfig.WebConfig.Session.SessionOn = true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants