From b03a77d2b7213bf9d99c7bf2e6f02e1d00287f77 Mon Sep 17 00:00:00 2001 From: gutmet Date: Thu, 5 Nov 2020 00:15:01 +0100 Subject: [PATCH] close output file after write --- TDL.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/TDL.go b/TDL.go index f469b34..f7b150b 100644 --- a/TDL.go +++ b/TDL.go @@ -26,7 +26,7 @@ func checkUsage(debugFlag string, args []string) { } } -func outfile(infile string) io.Writer { +func outfile(infile string) *os.File { basename := path.Base(infile) extension := path.Ext(basename) basename = strings.TrimSuffix(basename, extension) @@ -67,7 +67,9 @@ func main() { if stdout { writer = os.Stdout } else { - writer = outfile(filename) + out := outfile(filename) + defer out.Close() + writer = out } generator := NewStdGenerator(writer) generator.Generate(parsed)