From 0de038534d16c4c9de1dbeeac9395d1024d3f17f Mon Sep 17 00:00:00 2001 From: Ardika Bagus Date: Fri, 3 Nov 2023 16:36:59 +0700 Subject: [PATCH] chore: catch error during write to stdout Signed-off-by: Ardika Bagus --- cmd/root.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/root.go b/cmd/root.go index e8bd04f..3b16e2d 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -65,7 +65,10 @@ func run(cmd *cobra.Command, args []string) error { generatedObjects = append(generatedObjects, generated...) } - os.Stdout.Write([]byte(generatedObjects.String())) + if _, err := os.Stdout.Write([]byte(generatedObjects.String())); err != nil { + return err + } + return nil }