diff options
author | Steve Manuel <nilslice@gmail.com> | 2016-09-24 00:10:41 -0700 |
---|---|---|
committer | Steve Manuel <nilslice@gmail.com> | 2016-09-24 00:10:41 -0700 |
commit | e39696e4be3573bc2c131ccd2f92a07307e1f4ca (patch) | |
tree | d0b465259f479eaf96af418f706ad0f1368a2188 | |
parent | a454791d5abbba77f6aedb6105edda70d0f52504 (diff) |
adding Init func to db instead of native init func so that when cms is called as a CLI, it does not create the db file in the current directory erroneously
-rw-r--r-- | cmd/cms/main.go | 3 | ||||
-rw-r--r-- | system/db/query.go | 3 |
2 files changed, 5 insertions, 1 deletions
diff --git a/cmd/cms/main.go b/cmd/cms/main.go index 5550175..00b4809 100644 --- a/cmd/cms/main.go +++ b/cmd/cms/main.go @@ -4,6 +4,8 @@ import ( "flag" "fmt" "os" + + "github.com/nilslice/cms/system/db" ) var usage = ` @@ -95,6 +97,7 @@ func main() { os.Exit(1) } case "serve", "s": + db.Init() serve() case "": diff --git a/system/db/query.go b/system/db/query.go index 80a3412..480946f 100644 --- a/system/db/query.go +++ b/system/db/query.go @@ -18,7 +18,8 @@ import ( var store *bolt.DB -func init() { +// Init creates a db connection and initializes db with required info +func Init() { var err error store, err = bolt.Open("store.db", 0666, nil) if err != nil { |