From 93c18a7d4dd4eb8ee073382911db78f1a2b28860 Mon Sep 17 00:00:00 2001 From: Benoit Gagnon Date: Sat, 28 Sep 2019 10:56:47 -0400 Subject: [PATCH] motivate the explicit f.Close() --- pkg/git.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/git.go b/pkg/git.go index d337824..b8d39c7 100644 --- a/pkg/git.go +++ b/pkg/git.go @@ -141,6 +141,10 @@ func gzipUntar(dst string, r io.Reader, subDir string) error { if _, err := io.Copy(f, tr); err != nil { return err } + + // Explicitly release the file handle inside the inner loop + // Using defer would accumulate an unbounded quantity of + // handles and release them all at once at function end. f.Close() } }