mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-19 03:54:01 +00:00
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:
committed by
Ron Evans
parent
5a70c88483
commit
d41f01f003
+1
-5
@@ -114,11 +114,7 @@ func runTest(path, target string, t *testing.T) {
|
|||||||
if path[len(path)-1] == os.PathSeparator {
|
if path[len(path)-1] == os.PathSeparator {
|
||||||
txtpath = path + "out.txt"
|
txtpath = path + "out.txt"
|
||||||
}
|
}
|
||||||
f, err := os.Open(txtpath)
|
expected, err := ioutil.ReadFile(txtpath)
|
||||||
if err != nil {
|
|
||||||
t.Fatal("could not open expected output file:", err)
|
|
||||||
}
|
|
||||||
expected, err := ioutil.ReadAll(f)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("could not read expected output file:", err)
|
t.Fatal("could not read expected output file:", err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user