Simplify error handling during startup
This commit is contained in:
parent
969dbfb1aa
commit
4b2fcbc58a
5 changed files with 29 additions and 54 deletions
|
|
@ -2,25 +2,27 @@ package store
|
|||
|
||||
import (
|
||||
"database/sql"
|
||||
"log"
|
||||
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
)
|
||||
|
||||
type Store struct {
|
||||
db *sql.DB
|
||||
db *sql.DB
|
||||
cakes []Cake
|
||||
}
|
||||
|
||||
func OpenStore(filename string) (*Store, error) {
|
||||
func OpenStore(filename string) *Store {
|
||||
var out Store
|
||||
var err error
|
||||
|
||||
out.db, err = sql.Open("sqlite3", filename)
|
||||
if err != nil {
|
||||
return &out, err
|
||||
log.Fatal("Can't open the database", filename, err)
|
||||
}
|
||||
|
||||
err = out.loadMigrations()
|
||||
return &out, err
|
||||
out.loadMigrations()
|
||||
return &out
|
||||
}
|
||||
|
||||
func (s *Store) Close() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue