aboutsummaryrefslogtreecommitdiff
path: root/bolt.go
diff options
context:
space:
mode:
authorBen Johnson <benbjohnson@yahoo.com>2014-02-26 16:32:05 -0700
committerBen Johnson <benbjohnson@yahoo.com>2014-02-26 16:32:40 -0700
commita47c50295a24c50872afc183927e34eec5c3dbdf (patch)
treeb14c3f9b43c91608a85282ab11c013600633a16c /bolt.go
parentRemove RWTransaction.Bucket(). (diff)
downloaddedo-a47c50295a24c50872afc183927e34eec5c3dbdf.tar.gz
dedo-a47c50295a24c50872afc183927e34eec5c3dbdf.tar.xz
Add bolt.Open().
Per the suggestion of @tv42 and @cespare, this commit adds a package level function to create and initialize a database at a given path. This is a common interface for database packages.
Diffstat (limited to 'bolt.go')
-rw-r--r--bolt.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/bolt.go b/bolt.go
new file mode 100644
index 0000000..bb5a2de
--- /dev/null
+++ b/bolt.go
@@ -0,0 +1,15 @@
+package bolt
+
+import (
+ "os"
+)
+
+// Open creates and opens a database at the given path.
+// If the file does not exist then it will be created automatically.
+func Open(path string, mode os.FileMode) (*DB, error) {
+ db := &DB{}
+ if err := db.Open(path, mode); err != nil {
+ return nil, err
+ }
+ return db, nil
+}