From 93959269ad99e80983c9ba742a7e01203a4c0e4f Mon Sep 17 00:00:00 2001 From: Phillip Johnsen Date: Mon, 5 Feb 2018 23:42:58 +0100 Subject: [PATCH] Add Execute func example in README.md (#629) Trivial addition to the first example in `README.md` that defines the `cmd.Execute()` function that is referenced further down in the `main.go` example. --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 42aad4bb..851fcc08 100644 --- a/README.md +++ b/README.md @@ -192,6 +192,13 @@ var rootCmd = &cobra.Command{ // Do Stuff Here }, } + +func Execute() { + if err := rootCmd.Execute(); err != nil { + fmt.Println(err) + os.Exit(1) + } +} ``` You will additionally define flags and handle configuration in your init() function.