cobra is a very handy and popular Go package that allows you to develop command-line utilities with commands, subcommands, and aliases. If you have ever used hugo, docker, or kubectl you will understand immediately what Cobra does, as all these tools were developed using cobra.
As you will see in this section, commands in cobra can have one or more aliases, which is very handy when you want to please both amateur and experienced users. cobra also supports Persistent Flags and Local Flags, which are flags that are available to all commands and flags that are available to a given command only, respectively. Also, by default, cobra uses viper for parsing its command-line arguments.
All cobra projects follow the same development pattern. You use the cobra tool, then you create commands, and then you make the desired changes to the generated Go source code files...