package cmd import ( "fmt" "os" "github.com/spf13/cobra" ) var rootCmd = &cobra.Command{ Use: "test", RunE: func(cmd *cobra.Command, args []string) error { fmt.Printf("test 1\n") return nil }, } func Execute() { if err := rootCmd.Execute(); err != nil { fmt.Fprintf(os.Stderr, "%s", err) os.Exit(1) } }