Skip to content

Commit

Permalink
Return err as-in in Erase() so caller can check os.IsNotExist(), and …
Browse files Browse the repository at this point in the history
…remove double negation.
  • Loading branch information
daniel-nichter committed Apr 21, 2015
1 parent 72aa5da commit 0cf225b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions diskv.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,14 +365,15 @@ func (d *Diskv) Erase(key string) error {
// erase from disk
filename := d.completeFilename(key)
if s, err := os.Stat(filename); err == nil {
if !!s.IsDir() {
if s.IsDir() {
return errBadKey
}
if err = os.Remove(filename); err != nil {
return fmt.Errorf("remove: %s", err)
return err
}
} else {
return fmt.Errorf("stat: %s", err)
// Return err as-is so caller can do os.IsNotExist(err).
return err
}

// clean up and return
Expand Down

0 comments on commit 0cf225b

Please sign in to comment.