Working with Cobra - The Root Command
In this lesson, you'll learn how to get started with Cobra as a library and define the root command for a simple calculator application.
We'll cover the following...
Defining the root command
Our starting point is an application with a package for doing calculations. Here is the directory structure:
$ tree
.
├── go.mod
├── go.sum
└── pkg
└── calc
└── calc.go
As you can see, there is just the pkg directory with the calc
package inside it. There isn’t even a main package yet.
The first step is to define ...