Files
gonic/db/db.go
2019-04-30 17:16:47 +01:00

23 lines
354 B
Go

package db
import (
"log"
"runtime"
"github.com/jinzhu/gorm"
)
var (
// cFile is the path to this go file
_, cFile, _, _ = runtime.Caller(0)
)
// New creates a new GORM connection to the database
func New() *gorm.DB {
db, err := gorm.Open("sqlite3", "gonic.db")
if err != nil {
log.Printf("when opening database: %v\n", err)
}
return db
}