初始化Go学习项目

This commit is contained in:
liumangmang
2025-12-26 17:56:02 +08:00
commit 7f4527d501
90 changed files with 3436 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
package main
import (
"fmt"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
)
// // User 模型
//
// type User struct {
// ID uint `gorm:"primaryKey"`
// Name string `gorm:"size:100;not null"`
// Email string `gorm:"size:100;unique;not null"`
// Age int `gorm:"default:0"`
// Active bool `gorm:"default:true"`
// CreatedAt time.Time
// UpdatedAt time.Time
// }
func main() {
db, _ := gorm.Open(sqlite.Open("test.db"), &gorm.Config{})
// 自动迁移(创建表)
db.AutoMigrate(&User{})
fmt.Println("Table created successfully!")
}