mirror of https://github.com/etcd-io/bbolt.git
chore: use errors.New to replace fmt.Errorf with no parameters will much better
Signed-off-by: ChengenH <hce19970702@gmail.com>pull/735/head
parent
5ae7bc66ce
commit
b005c0c435
|
@ -302,7 +302,7 @@ You can retrieve an existing bucket using the `Tx.Bucket()` function:
|
||||||
db.Update(func(tx *bolt.Tx) error {
|
db.Update(func(tx *bolt.Tx) error {
|
||||||
b := tx.Bucket([]byte("MyBucket"))
|
b := tx.Bucket([]byte("MyBucket"))
|
||||||
if b == nil {
|
if b == nil {
|
||||||
return fmt.Errorf("bucket does not exist")
|
return errors.New("bucket does not exist")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
|
@ -44,7 +44,7 @@ func (o *surgeryBaseOptions) AddFlags(fs *pflag.FlagSet) {
|
||||||
|
|
||||||
func (o *surgeryBaseOptions) Validate() error {
|
func (o *surgeryBaseOptions) Validate() error {
|
||||||
if o.outputDBFilePath == "" {
|
if o.outputDBFilePath == "" {
|
||||||
return fmt.Errorf("output database path wasn't given, specify output database file path with --output option")
|
return errors.New("output database path wasn't given, specify output database file path with --output option")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -392,7 +392,7 @@ func (cmd *pageItemCommand) Run(args ...string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if options.keyOnly && options.valueOnly {
|
if options.keyOnly && options.valueOnly {
|
||||||
return fmt.Errorf("The --key-only or --value-only flag may be set, but not both.")
|
return errors.New("The --key-only or --value-only flag may be set, but not both.")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Require database path and page id.
|
// Require database path and page id.
|
||||||
|
@ -1675,7 +1675,7 @@ func (cmd *compactCommand) Run(args ...string) (err error) {
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
return err
|
return err
|
||||||
} else if cmd.DstPath == "" {
|
} else if cmd.DstPath == "" {
|
||||||
return fmt.Errorf("output file required")
|
return errors.New("output file required")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Require database paths.
|
// Require database paths.
|
||||||
|
|
2
db.go
2
db.go
|
@ -562,7 +562,7 @@ func (db *DB) mmapSize(size int) (int, error) {
|
||||||
|
|
||||||
// Verify the requested size is not above the maximum allowed.
|
// Verify the requested size is not above the maximum allowed.
|
||||||
if size > maxMapSize {
|
if size > maxMapSize {
|
||||||
return 0, fmt.Errorf("mmap too large")
|
return 0, errors.New("mmap too large")
|
||||||
}
|
}
|
||||||
|
|
||||||
// If larger than 1GB then grow by 1GB at a time.
|
// If larger than 1GB then grow by 1GB at a time.
|
||||||
|
|
Loading…
Reference in New Issue