mirror of
https://github.com/etcd-io/bbolt.git
synced 2025-05-01 21:19:39 +00:00
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.
16 lines
310 B
Go
16 lines
310 B
Go
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
|
|
}
|