Closed wdullaer closed 4 years ago
Cobra will print a stacktrace if you forcibly close the process from within a cmd.Run function. Using RunE and returning errors will prevent this.
cmd.Run
RunE
Cobra will print errors returned this way for you, so the fmt.Println(err) in rootCmd was redundant.
fmt.Println(err)
rootCmd
You may also want to do this in the serve command, but I did not touch it right now.
serve
Thanks @wdullaer. 👍 LGTM.
Cobra will print a stacktrace if you forcibly close the process from within a
cmd.Run
function. UsingRunE
and returning errors will prevent this.Cobra will print errors returned this way for you, so the
fmt.Println(err)
inrootCmd
was redundant.You may also want to do this in the
serve
command, but I did not touch it right now.