From 7cab6be2ae419b6ca22762a8402b26670d4e27a0 Mon Sep 17 00:00:00 2001 From: Ishan Tyagi Date: Wed, 26 Jul 2023 00:27:33 +0530 Subject: [PATCH] Documentation: standardised examples in README.md to use file mode:0600 Signed-off-by: Ishan Tyagi --- README.md | 4 ++-- db.go | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a23ddf9..254f027 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,7 @@ To use bbolt as an embedded key-value store, import as: ```go import bolt "go.etcd.io/bbolt" -db, err := bolt.Open(path, 0666, nil) +db, err := bolt.Open(path, 0600, nil) if err != nil { return err } @@ -664,7 +664,7 @@ uses a shared lock to allow multiple processes to read from the database but it will block any processes from opening the database in read-write mode. ```go -db, err := bolt.Open("my.db", 0666, &bolt.Options{ReadOnly: true}) +db, err := bolt.Open("my.db", 0600, &bolt.Options{ReadOnly: true}) if err != nil { log.Fatal(err) } diff --git a/db.go b/db.go index 4a73ce1..0d35861 100644 --- a/db.go +++ b/db.go @@ -164,9 +164,10 @@ func (db *DB) String() string { return fmt.Sprintf("DB<%q>", db.path) } -// Open creates and opens a database at the given path. -// If the file does not exist then it will be created automatically. +// Open creates and opens a database at the given path with a given file mode. +// If the file does not exist then it will be created automatically with a given file mode. // Passing in nil options will cause Bolt to open the database with the default options. +// Note: For read/write transactions, ensure the owner has write permission on the created/opened database file, e.g. 0600 func Open(path string, mode os.FileMode, options *Options) (*DB, error) { db := &DB{ opened: true,