go-admin-team / go-admin

基于Gin + Vue + Element UI & Arco Design & Ant Design 的前后端分离权限管理系统脚手架(包含了:多租户的支持,基础用户管理功能,jwt鉴权,代码生成器,RBAC资源控制,表单构建,定时任务等)3分钟构建自己的中后台项目;项目文档》:https://www.go-admin.pro V2 Demo: https://vue2.go-admin.dev V3 Demo: https://vue3.go-admin.dev Antd PRO:https://antd.go-admin.pro
https://www.go-admin.pro
MIT License
11.42k stars 2.37k forks source link

go-admin启动服务($ ./go-admin server)时,报"panic: runtime error: invalid memory address or nil pointer dereference" #406

Closed stonecity closed 3 years ago

stonecity commented 3 years ago

2021-04-29T16:20:16.682+0800 file: gorm@v1.21.6/callbacks.go:127 level: trace D:/Program Files/Golearn/pkg/mod/github.com/go-admin-team/gorm-adapter/v3@v3.2.1-0.20210310135230-1608cc35b95b/adapter.go:362 [0.889ms] [rows:1] SELECT FROM sys_casbin_rule 2021-04-29T16:20:16.683+0800 file: gorm@v1.21.6/callbacks.go:127 level: trace D:/Program Files/Golearn/pkg/mod/github.com/go-admin-team/gorm-adapter/v3@v3.2.1-0.20210310135230-1608cc35b95b/adapter.go:362 [0.516ms] [rows:1] SELECT FROM sys_casbin_rule panic: runtime error: invalid memory address or nil pointer dereference [signal 0xc0000005 code=0x0 addr=0x0 pc=0xe2769d]

goroutine 1 [running]: github.com/go-admin-team/go-admin-core/sdk/config.Queue.Setup(0x0, 0x0, 0xc0004477c0, 0x2cbc6f8, 0xc0004477c0, 0x0) D:/Program Files/Golearn/pkg/mod/github.com/go-admin-team/go-admin-core/sdk@v1.3.5-rc.0/config/queue.go:47 +0x1fd go-admin/cmd/api.setup() D:/Product/mile/Project/go-admin/cmd/api/server.go:79 +0x269 go-admin/cmd/api.glob..func1(0x274b2c0, 0x3455f70, 0x0, 0x0) D:/Product/mile/Project/go-admin/cmd/api/server.go:37 +0x27 github.com/spf13/cobra.(Command).execute(0x274b2c0, 0x3455f70, 0x0, 0x0, 0x274b2c0, 0x3455f70) D:/Program Files/Golearn/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:835 +0x4ef github.com/spf13/cobra.(Command).ExecuteC(0x274b020, 0x131f6b0, 0x0, 0x1) D:/Program Files/Golearn/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:950 +0x375 github.com/spf13/cobra.(*Command).Execute(...) D:/Program Files/Golearn/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:887 go-admin/cmd.Execute() D:/Product/mile/Project/go-admin/cmd/cobra.go:52 +0x34 main.main() D:/Product/mile/Project/go-admin/main.go:20 +0x27

hsluoyz commented 3 years ago

@closetool

kilosonc commented 3 years ago

@stonecity plz run it with gorm v1.20.x

hsluoyz commented 3 years ago

@closetool why does it happen? Can we just lock dependency to v1.20.x?

iwalben commented 3 years ago

@closetool why does it happen? Can we just lock dependency to v1.20.x?

i have the same error with you

i fixed it like blow,but it still not working require ( github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 github.com/alibaba/sentinel-golang v0.6.1 github.com/aliyun/aliyun-oss-go-sdk v0.0.0-20190307165228-86c17b95fcd5 github.com/bytedance/go-tagexpr/v2 v2.7.10 github.com/casbin/casbin/v2 v2.25.1 github.com/gin-gonic/gin v1.6.3 github.com/go-admin-team/go-admin-core v1.3.4 github.com/go-admin-team/go-admin-core/plugins/logger/zap v1.3.0 // indirect github.com/google/uuid v1.2.0 github.com/jinzhu/now v1.1.2 // indirect github.com/mssola/user_agent v0.5.2 github.com/opentracing/opentracing-go v1.1.0 github.com/prometheus/client_golang v1.1.0 github.com/robfig/cron/v3 v3.0.1 github.com/shirou/gopsutil v2.20.7+incompatible github.com/spf13/cast v1.3.1 github.com/spf13/cobra v1.0.0 github.com/swaggo/gin-swagger v1.2.0 github.com/swaggo/swag v1.6.7 github.com/unrolled/secure v1.0.8 golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83 golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect gorm.io/driver/mysql v1.0.4-0.20201206014609-ae5fd10184f6 gorm.io/driver/postgres v1.0.6-0.20201208020313-1ed927cfab53 gorm.io/driver/sqlite v1.1.5-0.20201206014648-c84401fbe3ba gorm.io/gorm v1.20.12 // indirect )

hsluoyz commented 3 years ago

@closetool

kilosonc commented 3 years ago

@hsluoyz https://github.com/golang/go/wiki/Modules#version-selection for they import gorm 1.21.x and go mod would choose higher version, instead of the version defined in gorm-adapter go.mod file

hsluoyz commented 3 years ago

@closetool this repo still uses Gorm v1.21.6:

https://github.com/go-admin-team/go-admin/blob/bf7934c20af9a45be989a4ea9905099380554468/go.mod#L30

Based on our previous issue: https://github.com/casbin/gorm-adapter/issues/98#issuecomment-825492311

Thanks @hsluoyz Works fine with 1.20.x and as well with the latest 1.21.8

Can we upgrade the Gorm version in this repo to latest 1.21.8 to fix this issue? If yes, plz make a PR.

BTW, I think latest version is 1.21.9: https://github.com/go-gorm/gorm/tags

hsluoyz commented 3 years ago

@closetool plz make PR to update go-admin to use Gorm adapter v3.2.12: https://github.com/casbin/gorm-adapter/pull/107#issuecomment-830576044

kilosonc commented 3 years ago

@hsluoyz go-admin does not import gorm-adapter in go.mod https://github.com/go-admin-team/go-admin/blob/master/go.mod

hsluoyz commented 3 years ago

@closetool I think it uses this https://github.com/go-admin-team/gorm-adapter ? It's a fork of ours. Then we should update this fork to rebased on our master HEAD. Then update the dependency on the fork repo.

wenjianzhang commented 3 years ago
queue:
    memory:
      poolSize: 100

append in config file