From d41f01f0031821f17667479cb89aacc47c88ca59 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Sat, 21 Dec 2019 20:09:34 +0100 Subject: [PATCH] main: avoid leaving files open Eventually, open files should be closed when the GC runs and the finalizer is called. However we shouldn't rely on that. Using `ioutil.ReadFile` as it's a simpler pattern anyway. --- main_test.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/main_test.go b/main_test.go index 3568f4c9..bb04c394 100644 --- a/main_test.go +++ b/main_test.go @@ -114,11 +114,7 @@ func runTest(path, target string, t *testing.T) { if path[len(path)-1] == os.PathSeparator { txtpath = path + "out.txt" } - f, err := os.Open(txtpath) - if err != nil { - t.Fatal("could not open expected output file:", err) - } - expected, err := ioutil.ReadAll(f) + expected, err := ioutil.ReadFile(txtpath) if err != nil { t.Fatal("could not read expected output file:", err) }