aboutsummaryrefslogtreecommitdiff
path: root/cmd/bolt/set.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/bolt/set.go')
-rw-r--r--cmd/bolt/set.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/cmd/bolt/set.go b/cmd/bolt/set.go
index 9761f44..c757d27 100644
--- a/cmd/bolt/set.go
+++ b/cmd/bolt/set.go
@@ -21,6 +21,12 @@ func Set(path, name, key, value string) {
defer db.Close()
err = db.Update(func(tx *bolt.Tx) error {
+ // Create the bucket if it doesn't exist.
+ if err := tx.CreateBucketIfNotExists([]byte(name)); err != nil {
+ fatalf("create bucket: %s", err)
+ return nil
+ }
+
// Find bucket.
b := tx.Bucket([]byte(name))
if b == nil {