部分尝试
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
|
passwd string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (User) TableName() string {
|
|
||||||
return "user"
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
dsn := "host=localhost " +
|
dsn := "host=localhost " +
|
||||||
"user=gatekeeper " +
|
"user=gatekeeper " +
|
||||||
@@ -33,11 +29,9 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic("无法连接数据库")
|
panic("无法连接数据库")
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
user, err := gorm.G[User](db).First(ctx)
|
usr, err := gorm.G[User](db).First(ctx)
|
||||||
fmt.Println(user)
|
fmt.Println(usr)
|
||||||
fmt.Println("程序结束")
|
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