From dfef622df20ba24082fe220c96ba3219fa0924b0 Mon Sep 17 00:00:00 2001 From: Tom Wilkie Date: Sun, 12 Mar 2017 13:33:26 +0000 Subject: [PATCH] Make sure you close files after opening them. --- analysis.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/analysis.go b/analysis.go index ad0b81a234..9a071c91f5 100644 --- a/analysis.go +++ b/analysis.go @@ -112,13 +112,15 @@ func ListPackages(fileRoot, importRoot string) (PackageTree, error) { // would have an err with the same path as is called this time, as only // then will filepath.Walk have attempted to descend into the directory // and encountered an error. - _, err = os.Open(wp) + var f *os.File + f, err = os.Open(wp) if err != nil { if os.IsPermission(err) { return filepath.SkipDir } return err } + defer f.Close() // Compute the import path. Run the result through ToSlash(), so that // windows file paths are normalized to slashes, as is expected of