Skip to content

Commit

Permalink
chore: use errors.New to replace fmt.Errorf with no parameters will m…
Browse files Browse the repository at this point in the history
…uch better

Signed-off-by: ChengenH <hce19970702@gmail.com>
  • Loading branch information
ChengenH committed Apr 21, 2024
1 parent 5ae7bc6 commit b005c0c
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ You can retrieve an existing bucket using the `Tx.Bucket()` function:
db.Update(func(tx *bolt.Tx) error {
b := tx.Bucket([]byte("MyBucket"))
if b == nil {
return fmt.Errorf("bucket does not exist")
return errors.New("bucket does not exist")
}
return nil
})
Expand Down
2 changes: 1 addition & 1 deletion cmd/bbolt/command_surgery.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (o *surgeryBaseOptions) AddFlags(fs *pflag.FlagSet) {

func (o *surgeryBaseOptions) Validate() error {
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
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/bbolt/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ func (cmd *pageItemCommand) Run(args ...string) error {
}

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.
Expand Down Expand Up @@ -1675,7 +1675,7 @@ func (cmd *compactCommand) Run(args ...string) (err error) {
} else if err != nil {
return err
} else if cmd.DstPath == "" {
return fmt.Errorf("output file required")
return errors.New("output file required")
}

// Require database paths.
Expand Down
2 changes: 1 addition & 1 deletion db.go
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ func (db *DB) mmapSize(size int) (int, error) {

// Verify the requested size is not above the maximum allowed.
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.
Expand Down

0 comments on commit b005c0c

Please sign in to comment.