部分尝试

This commit is contained in:
des
2026-01-12 18:38:40 +08:00
parent becb6a512b
commit d7854bbf1d
3 changed files with 4 additions and 8 deletions

View File

@@ -18,10 +18,6 @@ type User struct {
passwd string
}
func (User) TableName() string {
return "user"
}
func main() {
dsn := "host=localhost " +
"user=gatekeeper " +
@@ -33,11 +29,9 @@ func main() {
if err != nil {
panic("无法连接数据库")
}
ctx := context.Background()
user, err := gorm.G[User](db).First(ctx)
fmt.Println(user)
usr, err := gorm.G[User](db).First(ctx)
fmt.Println(usr)
fmt.Println("程序结束")
return
}