From 7c93217f5c6b2eb8830ddc1d6ed395f567832af6 Mon Sep 17 00:00:00 2001 From: Dave Henderson Date: Tue, 29 Sep 2020 20:07:46 -0400 Subject: Lint fixes Signed-off-by: Dave Henderson --- cmd/gomplate/main.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'cmd/gomplate/main.go') diff --git a/cmd/gomplate/main.go b/cmd/gomplate/main.go index ab52c630..730ac8eb 100644 --- a/cmd/gomplate/main.go +++ b/cmd/gomplate/main.go @@ -150,6 +150,11 @@ func initFlags(command *cobra.Command) { } func main() { + exitCode := 0 + // defer the exit first to make sure that other deferred functions have a + // chance to run + defer func() { os.Exit(exitCode) }() + ctx, cancel := context.WithCancel(context.Background()) defer cancel() ctx = initLogger(ctx) @@ -158,6 +163,7 @@ func main() { initFlags(command) if err := command.ExecuteContext(ctx); err != nil { log := zerolog.Ctx(ctx) - log.Fatal().Err(err).Send() + log.Error().Err(err).Send() + exitCode = 1 } } -- cgit v1.2.3