From 7cb6ebf14d59eedf48fa8a884fc0b4f69e7a9db3 Mon Sep 17 00:00:00 2001 From: songzhibin97 <718428482@qq.com> Date: Sun, 21 Apr 2024 09:53:00 +0800 Subject: [PATCH] feat: more same case --- cmd/geth/logging_test.go | 2 ++ cmd/utils/history_test.go | 1 + core/mkalloc.go | 1 + 3 files changed, 4 insertions(+) diff --git a/cmd/geth/logging_test.go b/cmd/geth/logging_test.go index b5ce03f4b8..f426b138bb 100644 --- a/cmd/geth/logging_test.go +++ b/cmd/geth/logging_test.go @@ -73,6 +73,7 @@ func testConsoleLogging(t *testing.T, format string, tStart, tEnd int) { if err != nil { t.Fatal(err) } + defer readFile.Close() wantLines := split(readFile) haveLines := split(bytes.NewBuffer(haveB)) for i, want := range wantLines { @@ -109,6 +110,7 @@ func TestJsonLogging(t *testing.T) { if err != nil { t.Fatal(err) } + defer readFile.Close() wantLines := split(readFile) haveLines := split(bytes.NewBuffer(haveB)) for i, wantLine := range wantLines { diff --git a/cmd/utils/history_test.go b/cmd/utils/history_test.go index b6703c59ed..520a0d84cd 100644 --- a/cmd/utils/history_test.go +++ b/cmd/utils/history_test.go @@ -113,6 +113,7 @@ func TestHistoryImportAndExport(t *testing.T) { if err != nil { t.Fatalf("error opening era file: %v", err) } + defer f.Close() var ( h = sha256.New() buf = bytes.NewBuffer(nil) diff --git a/core/mkalloc.go b/core/mkalloc.go index 201c2fe7de..cc4955f038 100644 --- a/core/mkalloc.go +++ b/core/mkalloc.go @@ -101,6 +101,7 @@ func main() { if err != nil { panic(err) } + defer file.Close() if err := json.NewDecoder(file).Decode(g); err != nil { panic(err) }