diff options
author | Steve Manuel <nilslice@gmail.com> | 2017-01-10 12:38:40 -0800 |
---|---|---|
committer | Steve Manuel <nilslice@gmail.com> | 2017-01-10 12:38:40 -0800 |
commit | 4415d2e915fda066a4ee092dc51311edc2e74100 (patch) | |
tree | d6dce722b9397ec868ce54d7cb084571ce01ad15 /system/db/init.go | |
parent | 820c24f827bf01cc44d22be492d407372c1a416a (diff) |
adding db open back to Init and calling Init from other files init()
Diffstat (limited to 'system/db/init.go')
-rw-r--r-- | system/db/init.go | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/system/db/init.go b/system/db/init.go index e85304c..6bc4753 100644 --- a/system/db/init.go +++ b/system/db/init.go @@ -13,14 +13,6 @@ import ( var store *bolt.DB -func init() { - var err error - store, err = bolt.Open("system.db", 0666, nil) - if err != nil { - log.Fatalln(err) - } -} - // Close exports the abillity to close our db file. Should be called with defer // after call to Init() from the same place. func Close() { @@ -32,7 +24,13 @@ func Close() { // Init creates a db connection, initializes db with required info, sets secrets func Init() { - err := store.Update(func(tx *bolt.Tx) error { + var err error + store, err = bolt.Open("system.db", 0666, nil) + if err != nil { + log.Fatalln(err) + } + + err = store.Update(func(tx *bolt.Tx) error { // initialize db with all content type buckets & sorted bucket for type for t := range item.Types { _, err := tx.CreateBucketIfNotExists([]byte(t)) |