mirror of https://github.com/etcd-io/bbolt.git
Documentation: standardised examples in README.md to use file mode:0600
Signed-off-by: Ishan Tyagi <ishantyagi25@gmail.com>pull/543/head
parent
4fab5d4de4
commit
7cab6be2ae
|
@ -101,7 +101,7 @@ To use bbolt as an embedded key-value store, import as:
|
||||||
```go
|
```go
|
||||||
import bolt "go.etcd.io/bbolt"
|
import bolt "go.etcd.io/bbolt"
|
||||||
|
|
||||||
db, err := bolt.Open(path, 0666, nil)
|
db, err := bolt.Open(path, 0600, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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.
|
it will block any processes from opening the database in read-write mode.
|
||||||
|
|
||||||
```go
|
```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 {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
5
db.go
5
db.go
|
@ -164,9 +164,10 @@ func (db *DB) String() string {
|
||||||
return fmt.Sprintf("DB<%q>", db.path)
|
return fmt.Sprintf("DB<%q>", db.path)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open creates and opens a database at the given path.
|
// 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.
|
// 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.
|
// 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) {
|
func Open(path string, mode os.FileMode, options *Options) (*DB, error) {
|
||||||
db := &DB{
|
db := &DB{
|
||||||
opened: true,
|
opened: true,
|
||||||
|
|
Loading…
Reference in New Issue