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

Former-commit-id: 2ac565e4d78c22ffafc25532ef0771d4c8fa6da6 [formerly 2b65957a84d49a578c09e005d4100b269b6dc8e5] [formerly 115c739d59b0f5ff34de0f51588e973e94e77689 [formerly f0fbd2c30f]]
Former-commit-id: f28ba24ecfad414f37d054b6099aeb8480776914 [formerly d4e575940c207425c74141f5a78c43f5323d437c]
Former-commit-id: bc1dc9204608c1a4cca74639c46a6edbad8d37c6
This commit is contained in:
Travis Scholl
2016-02-07 10:15:42 -08:00
parent 2a83b3dd53
commit 322446ba18
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)