18 lines
273 B
Go
18 lines
273 B
Go
|
package db
|
||
|
|
||
|
import (
|
||
|
"github.com/jinzhu/gorm"
|
||
|
_ "github.com/jinzhu/gorm/dialects/sqlite"
|
||
|
)
|
||
|
|
||
|
var db *gorm.DB
|
||
|
|
||
|
func init() {
|
||
|
var err error
|
||
|
db, err = gorm.Open("sqlite3", "data.db")
|
||
|
if err != nil {
|
||
|
panic("failed to connect database")
|
||
|
}
|
||
|
db.AutoMigrate(&PingEntry{})
|
||
|
}
|