Prechádzať zdrojové kódy

fix: handle error closing file

Alex White 4 mesiacov pred
rodič
commit
90705cf18e
1 zmenil súbory, kde vykonal 6 pridanie a 1 odobranie
  1. 6 1
      simulator_test.go

+ 6 - 1
simulator_test.go

@@ -181,7 +181,12 @@ func TestSimulation_SimulateAllPossibleGamesFromGameLog(t *testing.T) {
 	if err != nil {
 		t.Fatalf("Error opening file: %s", err)
 	}
-	defer file.Close()
+	defer func(file *os.File) {
+		err := file.Close()
+		if err != nil {
+			t.Fatalf("Error closing file: %s", err)
+		}
+	}(file)
 
 	var words []string