From 1b005181951c0c36dba3bd5f3a213519cbed874c Mon Sep 17 00:00:00 2001 From: Harry Date: Fri, 9 Apr 2021 02:36:44 +0530 Subject: [PATCH] hotfix: fix double error message prints (#317) This incorrect change was introduced in 598f214. --- cmd/root.go | 8 ++++++-- main.go | 6 +----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index b33b2d341..5b33fbc5c 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -41,8 +41,12 @@ It can be used to export, import or sync entities to Kong.`, // Execute adds all child commands to the root command and sets // sflags appropriately. // This is called by main.main(). It only needs to happen once to the rootCmd. -func Execute() error { - return rootCmd.Execute() +func Execute() { + err := rootCmd.Execute() + if err != nil { + // do not print error because cobra already prints it + os.Exit(1) + } } //nolint:errcheck diff --git a/main.go b/main.go index d5f740ad4..4f7cfceda 100644 --- a/main.go +++ b/main.go @@ -26,11 +26,7 @@ func registerSignalHandler() { func main() { registerSignalHandler() - err := cmd.Execute() - if err != nil { - fmt.Println(err) - os.Exit(1) - } + cmd.Execute() } func init() {