The cobra package
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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access