19 lines
285 B
Go
19 lines
285 B
Go
package db
|
|
|
|
import (
|
|
"github.com/jinzhu/gorm"
|
|
_ "github.com/jinzhu/gorm/dialects/sqlite"
|
|
)
|
|
|
|
// InitDB load the database and the models
|
|
func InitDB() {
|
|
db, err := gorm.Open("sqlite3", "test.db")
|
|
if err != nil {
|
|
panic(err.Error())
|
|
}
|
|
defer db.Close()
|
|
|
|
db.AutoMigrate(&User{})
|
|
|
|
}
|