course/starbook/register-model #157
Replies: 1 comment
-
|
在这里其实会遇到mysql的相关问题。在gf 2.X版本中,会报如下错误: cannot find database driver for specified database type "xxx", did you misspell type name "xxx" or forget importing the database driver?就需要使用如下连接中的mysql:https://github.com/gogf/gf/tree/master/contrib/drivers require (
github.com/gogf/gf/contrib/drivers/mysql/v2 v2.8.3
github.com/gogf/gf/v2 v2.8.3
)执行 go get -u github.com/gogf/gf/contrib/drivers/mysql/v2这时候,执行gf run main.go 的时候会报错: build error:
../../pkg/mod/github.com/gogf/gf/contrib/drivers/mysql/[email protected]/mysql.go:11:2: missing go.sum entry for module providing package github.com/go-sql-driver/mysql (imported by github.com/gogf/gf/contrib/drivers/mysql/v2); to add:
go get github.com/gogf/gf/contrib/drivers/mysql/[email protected]
exit status 1需要清理依赖缓存和强制依赖,执行如下命令: go clean -modcache
go mod tidy然后再运行 gf run main.go 就能成功使用mysql啦。 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
course/starbook/register-model
在数据库中创建名为users的数据表用于储存用户信息,包括用户名和密码等字段,支持自动递增主键标识。通过修改配置文件和执行GF-CLI命令生成数据模型和数据访问对象,生成的四个文件在model和dao层负责管理数据结构和数据访问,GoFrame框架通过ORM实现对数据表的操作。
https://goframe.org/course/starbook/register-model
Beta Was this translation helpful? Give feedback.
All reactions