package dao import ( "fmt" "github.com/jinzhu/gorm" ) var Db *gorm.DB func InitDB(db *gorm.DB) { Db = db err := Db.AutoMigrate( &Library{}, ).Error if err != nil { panic(fmt.Sprintf("AutoMigrate err : %v", err)) } }