Comparing Cobra to Alternatives
Let's install Cobra and learn how Cobra can be used either as a library or as an application generator.
We'll cover the following
We will compare Cobra with some alternatives ways to parse command-line programs including the built-in ways Go provides as well as other third-party command-line parsing solutions.
Installing Cobra
First, we need to install Cobra. The official instructions recommend using the following command:
go get -u github.com/spf13/cobra/cobra
Unfortunately, this hangs indefinitely for me using Go 1.13.1. However, this command works:
go get -u github.com/spf13/cobra/cobra/...
Get hands-on with 1400+ tech skills courses.