From 33be6b9cf2fe73ce1f37d7edebcdb61ec8b1ff5c Mon Sep 17 00:00:00 2001 From: Shreyas Goenka Date: Thu, 29 Jun 2023 15:30:11 +0200 Subject: [PATCH] add close statements --- libs/git/clone.go | 1 + libs/zip/extract.go | 3 +++ 2 files changed, 4 insertions(+) diff --git a/libs/git/clone.go b/libs/git/clone.go index 419832592..32512c90f 100644 --- a/libs/git/clone.go +++ b/libs/git/clone.go @@ -33,6 +33,7 @@ func download(url string, dest string) error { if err != nil { return err } + defer f.Close() _, err = io.Copy(f, resp.Body) return err diff --git a/libs/zip/extract.go b/libs/zip/extract.go index da2879e39..e763b5492 100644 --- a/libs/zip/extract.go +++ b/libs/zip/extract.go @@ -13,6 +13,7 @@ func Extract(src string, dst string) error { if err != nil { return err } + defer zipReader.Close() return fs.WalkDir(zipReader, ".", func(path string, d fs.DirEntry, err error) error { if err != nil { @@ -28,11 +29,13 @@ func Extract(src string, dst string) error { if err != nil { return err } + defer targetFile.Close() sourceFile, err := zipReader.Open(path) if err != nil { return err } + defer sourceFile.Close() _, err = io.Copy(targetFile, sourceFile) return err