Getting Started

While you are welcome to provide your own organization, typically a Cobra-based
application will follow the following organizational structure:

  1. appName/
  2. cmd/
  3. add.go
  4. your.go
  5. commands.go
  6. here.go
  7. main.go

In a Cobra app, typically the main.go file is very bare. It serves one purpose: initializing Cobra.

  1. package main
  2. import (
  3. "{pathToYourApp}/cmd"
  4. )
  5. func main() {
  6. cmd.Execute()
  7. }