From 71befefea8393487da45e9504334dab6c0be1eac Mon Sep 17 00:00:00 2001 From: Patrice Ferlet Date: Thu, 5 May 2022 10:45:41 +0200 Subject: [PATCH] Better file closing --- generator/writer.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/generator/writer.go b/generator/writer.go index 56a0e58..c60e5f8 100644 --- a/generator/writer.go +++ b/generator/writer.go @@ -183,11 +183,14 @@ func Generate(p *compose.Parser, katernayVersion, appName, appVersion, composeFi default: fname := filepath.Join(templatesDir, n+"."+kind+".yaml") - fp, _ := os.Create(fname) + fp, err := os.Create(fname) + if err != nil { + log.Fatal(err) + } + defer fp.Close() enc := yaml.NewEncoder(fp) enc.SetIndent(2) enc.Encode(c) - fp.Close() } } }