1
0
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:
Travis Scholl
2016-02-07 10:15:42 -08:00
parent 8c52173484
commit f0fbd2c30f
3 changed files with 42 additions and 16 deletions

8
db.go
View File

@ -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)