diff --git a/cmd/root.go b/cmd/root.go index 41973fd..04011f8 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 fcb537f..c63295c 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) }