From 39df92f7399bdaa74c821d606e9322dd1332074a Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Tue, 21 Apr 2020 01:01:55 +0100 Subject: [PATCH] return any error from Close if no other error has occurred --- doublestar.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/doublestar.go b/doublestar.go index c7a5020..710a471 100644 --- a/doublestar.go +++ b/doublestar.go @@ -434,7 +434,11 @@ func doGlob(vos OS, basedir, pattern string, matches []string) (m []string, e er 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 {