diff --git a/cmd/root.go b/cmd/root.go index 41973fdbb648fb98333ed362bce79d02981b4036..04011f8a58e536b3f0d7486ad26b5ceb6e03ac04 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -74,8 +74,12 @@ func Execute() { if err := RootCmd.Execute(); err != nil { fmt.Println(err) + // flush before exit non-zero + glog.Flush() os.Exit(-1) } + // flush before exit + glog.Flush() } func init() { diff --git a/cmd/util.go b/cmd/util.go index fcb537f5f08bb8d29f23156c6951a1f5fb976926..c63295cc2ab0851b8b6ad68bd5241b2942fce0ec 100644 --- a/cmd/util.go +++ b/cmd/util.go @@ -35,6 +35,8 @@ func init() { func exitWithError(err error) { fmt.Fprintf(os.Stderr, "\n%v\n", err) + // flush before exit non-zero + glog.Flush() os.Exit(1) }