From 0cf225ba947bc0cebf3cf579b6612260061fe3ea Mon Sep 17 00:00:00 2001 From: Daniel Nichter Date: Mon, 20 Apr 2015 20:36:10 -0700 Subject: [PATCH] Return err as-in in Erase() so caller can check os.IsNotExist(), and remove double negation. --- diskv.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/diskv.go b/diskv.go index 60387ec..8bcf3b9 100644 --- a/diskv.go +++ b/diskv.go @@ -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