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.
This commit is contained in:
Ayke van Laethem
2019-12-21 20:09:34 +01:00
committed by Ron Evans
parent 5a70c88483
commit d41f01f003
+1 -5
View File
@@ -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)
}