common.go 230 B

123456789101112131415161718
  1. package dao
  2. import (
  3. "fmt"
  4. "github.com/jinzhu/gorm"
  5. )
  6. var Db *gorm.DB
  7. func InitDB(db *gorm.DB) {
  8. Db = db
  9. err := Db.AutoMigrate(
  10. &Library{},
  11. ).Error
  12. if err != nil {
  13. panic(fmt.Sprintf("AutoMigrate err : %v", err))
  14. }
  15. }