Move some things around a bit

This commit is contained in:
Brian Buller 2016-01-29 13:47:48 -06:00
parent 1c7863fe49
commit 116bfa95d8

View File

@ -2,7 +2,7 @@ package main
import (
"fmt"
"github.com/boltdb/bolt"
"github.com/br0xen/bolt"
"os"
"strings"
)
@ -15,17 +15,26 @@ func main() {
}
filename := args[0]
var db *bolt.DB
var err error
if len(args) > 1 && args[1] == "build" {
if _, err := os.Stat(filename); err == nil {
if _, stat_err := os.Stat(filename); stat_err == nil {
fmt.Printf("Cowardly refusing to overwrite file: %s\n", filename)
return
}
}
db, err := bolt.Open(filename, 0600, nil)
if err != nil {
fmt.Println(err)
}
//opts := bolt.Options{0, true}
//db, err := bolt.Open(filename, 0600, &opts)
db, err = bolt.Open(filename, 0600, nil)
if err != nil {
fmt.Printf("Error opening DB: %s\n", err)
return
}
defer db.Close()
if len(args) > 1 {
@ -33,6 +42,8 @@ func main() {
createTestDatabase(db)
} else if args[1] == "json" {
jsonDatabase(db)
} else if args[1] == "go" {
fmt.Print(db.GoString())
}
} else {
printDatabase(db)