Skip to content
Myr

Add idiomatic handling of go error in distinct main func

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Bruce Downs · committed by Albert Nigmatzianov · parent af29f95 · Browse files · 2 files+14 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+14 added−4 removed

  • other:+14 added−4 removed

2 files+14 added−4 removed

modified:cobra/cmd/root.go+2 added-2 removed
34 unmodified lines
35 }36)3738// Execute executes the root command.39func Execute() {40 rootCmd.Execute()39func Execute() error {40 return rootCmd.Execute()41}4243func init() {44 cobra.OnInitialize(initConfig)
36 unmodified lines
modified:cobra/main.go+12 added-2 removed
11 unmodified lines
12// limitations under the License.1314package main1516import "github.com/spf13/cobra/cobra/cmd"16import (17 "os"1819 "github.com/spf13/cobra/cobra/cmd"20)2122func main() {19 cmd.Execute()23 if err := runMain(); err != nil {24 os.Exit(1)25 }26}2728func runMain() error {29 return cmd.Execute()30}