mirror of
https://github.com/schollz/cowyo.git
synced 2023-08-10 21:13:00 +03:00
used flag for command line arguments
This commit is contained in:
8
db.go
8
db.go
@ -4,8 +4,6 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"path"
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
"github.com/boltdb/bolt"
|
||||
@ -15,12 +13,10 @@ var db *bolt.DB
|
||||
var open bool
|
||||
|
||||
// Open to create the database and open
|
||||
func Open() error {
|
||||
func Open(filename string) error {
|
||||
var err error
|
||||
_, filename, _, _ := runtime.Caller(0) // get full path of this file
|
||||
dbfile := path.Join(path.Dir(filename), "data.db")
|
||||
config := &bolt.Options{Timeout: 30 * time.Second}
|
||||
db, err = bolt.Open(dbfile, 0600, config)
|
||||
db, err = bolt.Open(filename, 0600, config)
|
||||
if err != nil {
|
||||
fmt.Println("Opening BoltDB timed out")
|
||||
log.Fatal(err)
|
||||
|
Reference in New Issue
Block a user