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

当前默认版本Sqlite数据库初始化报错-已排查出原因 #777

Open
sunird opened this issue Nov 8, 2023 · 2 comments
Open

当前默认版本Sqlite数据库初始化报错-已排查出原因 #777

sunird opened this issue Nov 8, 2023 · 2 comments
Labels

Comments

@sunird
Copy link

sunird commented Nov 8, 2023

建议把open_sqlite3.go的功能启用,第一次下载[go-admin]想在本地测试一下,发现sqlite3功能不可用。报错:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x10.......]

调试了一下发现是go-admin-core@v1.5.2-0.20231103105356-84418ed9252c/tools/database/config.go,中的db, err := gorm.Open(open(e.dsn), config)部分使用的是open.go的代码没有引进sqlite驱动,其实open_sqlite3.go可以用的,可能会有些新手使用默认配置一直报错,排查花费时间

@xiliangMa
Copy link

sqlite3 数据库初始化失败
尝试CGO_ENABLED=1 go run -tags sqlite3 main.go migrate -c config/settings.sqlite.yml 可以解决

@lngwu11
Copy link

lngwu11 commented Jan 12, 2024

补充下,如果是生成可执行文件,编译时加上 -tags
$ go build -tags sqlite3

编译(在linux环境下)生成 go-admin,然后,
初始化数据库:
$ ./go-admin migrate -c config/settings.sqlite.yml
运行服务:
$ ./go-admin server -c config/settings.sqlite.yml

以上是针对使用sqlite数据库的情况

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

No branches or pull requests

3 participants