卓越飞翔博客卓越飞翔博客

卓越飞翔 - 您值得收藏的技术分享站
技术文章35551本站已运行397

Go Buffalo 测试出现 sqlite 错误:找不到名为 test 的连接

go buffalo 测试出现 sqlite 错误:找不到名为 test 的连接

php小编新一发现,在使用Go Buffalo进行测试时,可能会遇到sqlite错误,提示找不到名为test的连接。这个错误可能会影响测试的正常进行,需要我们找到解决办法。下面将介绍一些可能导致这个错误的原因,并提供解决方法,以帮助开发者顺利解决问题。

问题内容

我使用此命令创建的新项目出现 buffalo 测试错误。

buffalo new coke --db-type sqlite3
buffalo test

这是错误:

[POP] 2023/02/23 13:43:02 warn - unable to load connection development: could not create new connection: sqlite3 support was not compiled into the binary
[POP] 2023/02/23 13:43:02 warn - unable to load connection test: could not create new connection: sqlite3 support was not compiled into the binary
[POP] 2023/02/23 13:43:02 warn - unable to load connection production: could not create new connection: sqlite3 support was not compiled into the binary
Usage:
  buffalo test [flags]

Flags:
  -h, --help   help for test

ERRO[0000] Error: could not find connection named test  

在这个项目上运行测试之前我错过了什么吗?有人请告诉我。谢谢

解决方法

输出的第二行,

[pop] 2023/02/23 13:43:02 warn - <...>: sqlite3 support was not compiled into the binary

正如您在这里所看到的,根本原因是您的 buffalo 二进制文件未编译为支持 sqlite3。你是怎么安装的?如果您使用 go install,则应该使用 -tags sqlite 选项,因此命令应为

go install -tags sqlite github.com/gobuffalo/cli/cmd/buffalo@latest

请参阅文档了解更多安装选项。

https://gobuffalo.io/documentation/ get_started/installation/#custom-installation-with-sqlite3-support

卓越飞翔博客
上一篇: 将指针传递给 go defer 函数不起作用
下一篇: 返回列表
留言与评论(共有 0 条评论)
   
验证码:
隐藏边栏