...

/

Working with Cobra - The Sub-commands

Working with Cobra - The Sub-commands

In this lesson, we’ll define two sub-commands for the calculator application: the `add` and `subtract` commands which look very similar and can serve as a pattern to define additional sub-commands. Then, we'll connect the subcommands to the root command.

The add subcommand

Cobra is all about defining sub-commands. Let’s start with the add subcommand. It will be defined in the cmd/add.go ...