部分尝试
This commit is contained in:
1
srv/.gitignore
vendored
Normal file
1
srv/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
*.code-workspace
|
||||
10
srv/main.go
10
srv/main.go
@@ -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
|
||||
}
|
||||
|
||||
1
srv/test.sql
Normal file
1
srv/test.sql
Normal file
@@ -0,0 +1 @@
|
||||
DROP TABLE "user" ;
|
||||
Reference in New Issue
Block a user