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

please provide GORM example #308

Open
MushiTheMoshi opened this issue Dec 25, 2022 · 1 comment
Open

please provide GORM example #308

MushiTheMoshi opened this issue Dec 25, 2022 · 1 comment

Comments

@MushiTheMoshi
Copy link

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

@XiaoK29
Copy link

XiaoK29 commented Oct 26, 2023

你好呀,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)
}

}
`

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

No branches or pull requests

2 participants