0PricingLogin
Go Academy · Lesson

Cobra Fundamentals

Root command, Run, Args, and help generation

What is Cobra?

Cobra is the most popular Go library for building CLI applications. It provides commands, flags, subcommands, help generation, shell completion, and argument validation.

Installing Cobra

Add cobra as a dependency and optionally use the CLI generator:

go get github.com/spf13/cobra
// Optional: cobra-cli for scaffolding
go install github.com/spf13/cobra-cli@latest
cobra-cli init myapp

All lessons in this course

  1. Cobra Fundamentals
  2. Flags and Persistent Flags
  3. Subcommands and Command Groups
  4. Distributing CLI Tools
← Back to Go Academy