Search⌘ K
AI Features

The cobra Package I

Explore how to use the Cobra package to develop command-line tools in Go. Learn to add commands, set flags and aliases, and structure projects for building effective CLI utilities.

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 ...