The cobra Package I

Let’s set up our basic cobra package.

cobra is a very handy and popular Go package that allows us to develop command-line utilities with commands, subcommands, and aliases. If you have ever used hugo, docker, or kubectl, you are going to realize immediately what the cobra package does, as all these tools are developed using cobra. Commands can have one or more aliases, which is very handy when we 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 given commands only, respectively. Also, by default, cobra uses viper for ...

Get hands-on with 1400+ tech skills courses.