Like cli, cobra is a package for writing client binaries but takes a different approach. In cobra, we have to create separate commands and use them in our main app. We can install cobra using dep. Let's create our cobra project repository:
mkdir -p $GOPATH/src/github.com/git-user/chapter8/cobraCLI
Now, let's create another directory called cmd in the project for defining commands. In cobra apps, there will be a root command. This can have multiple subcommands. We can implement the same example we used for the flag package. Input the name and age from the command line using cobra.
Let's define a root command:
var rootCmd = &cobra.Command{
Use: "details",
Short: "This project takes student information",
Long: `A long string about description`,
Args: cobra.MinimumNArgs(1),
Run: func(cmd *cobra...