From 614284eea1b01641380ca8cb67445cb16829480d Mon Sep 17 00:00:00 2001 From: Jon Ayers Date: Thu, 15 Aug 2024 15:26:34 +0000 Subject: [PATCH] fix: print error to stdout prior to exiting --- cmd/envbox/main.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/envbox/main.go b/cmd/envbox/main.go index 813e62b..ebb77f9 100644 --- a/cmd/envbox/main.go +++ b/cmd/envbox/main.go @@ -2,6 +2,7 @@ package main import ( "context" + "fmt" "os" "os/signal" "runtime" @@ -17,8 +18,8 @@ func main() { sigs := make(chan os.Signal, 1) signal.Notify(sigs, syscall.SIGTERM, syscall.SIGINT, syscall.SIGWINCH) go func() { - log := slog.Make(slogjson.Sink(os.Stderr)) ctx := context.Background() + log := slog.Make(slogjson.Sink(os.Stderr)) log.Info(ctx, "waiting for signal") <-sigs log.Info(ctx, "got signal") @@ -38,6 +39,7 @@ func main() { }() _, err := cli.Root(ch).ExecuteC() if err != nil { + _, _ = fmt.Fprintln(os.Stderr, err.Error()) os.Exit(1) } runtime.Goexit()