package entities import ( "encoding/gob" "log" "gorm.io/gorm" ) func Init(db *gorm.DB) error { err := db.AutoMigrate( &User{}, &Project{}, &Build{}, &BuildStep{}, ) if err != nil { log.Fatalln(err) } err = db.Model(&User{}).FirstOrCreate(&User{ ID: 1, Username: "admin", RawPassword: "111111", }, User{ID: 1}).Error if err != nil { log.Fatalln(err) } // 使用 github.com/gorilla/sessions 需要 gob.Register(&User{}) return nil }