return any error from Close if no other error has occurred
diff --git a/doublestar.go b/doublestar.go
index c7a5020..710a471 100644
--- a/doublestar.go
+++ b/doublestar.go
@@ -434,7 +434,11 @@
 	if err != nil {
 		return
 	}
-	defer dir.Close()
+	defer func() {
+		if err := dir.Close(); e == nil {
+			e = err
+		}
+	}()
 
 	files, err := dir.Readdir(-1)
 	if err != nil {