go-sqlmock
go-sqlmock copied to clipboard
please provide GORM example
Hi there,
Hope you are well today.
Great work done here, really appreciated!
Wondering if you could possibly add an example about how to implement it in GORM?
I found some examples, though it'd be great come here only to see some examples about it.
Regards, Julio
你好呀,Hi there,
希望你今天一切都好。Hope you are well today.
在这里完成了出色的工作,非常感谢!Great work done here, really appreciated!
想知道您是否可以添加一个关于如何在 GORM 中实现它的示例?Wondering if you could possibly add an example about how to implement it in GORM?
我找到了一些例子,不过如果来这里只是为了看看一些关于它的例子就太好了。I found some examples, though it'd be great come here only to see some examples about it.
问候, 胡里奥Regards, Julio `package main
import ( "github.com/DATA-DOG/go-sqlmock" "gorm.io/driver/mysql" "gorm.io/gorm" )
func main() { _db, _, err := sqlmock.New() if err != nil { panic(err) }
db, err := gorm.Open(mysql.New(mysql.Config{
Conn: _db,
SkipInitializeWithVersion: true,
}))
if err != nil {
panic(err)
}
sqlDB, _ := db.DB()
if err := sqlDB.Ping(); err != nil {
panic(err)
}
} `