add close statements

This commit is contained in:
Shreyas Goenka 2023-06-29 15:30:11 +02:00
parent 8e92131a46
commit 33be6b9cf2
No known key found for this signature in database
GPG Key ID: 92A07DF49CCB0622
2 changed files with 4 additions and 0 deletions

View File

@ -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

View File

@ -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