21 lines
271 B
Go
21 lines
271 B
Go
|
package utils
|
||
|
|
||
|
import (
|
||
|
"database/sql"
|
||
|
"log"
|
||
|
|
||
|
_ "github.com/mattn/go-sqlite3"
|
||
|
)
|
||
|
|
||
|
func InitDB(filepath string) *sql.DB {
|
||
|
log.Printf("Init DB")
|
||
|
db, err := sql.Open("sqlite3", filepath)
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
if db == nil {
|
||
|
panic("db nil")
|
||
|
}
|
||
|
return db
|
||
|
}
|