The Creator's Corner

The Creator’s Corner: Resources by Steve Francia (spf13)

To truly understand Cobra and Viper is to understand the vision and philosophy behind their creation. This section highlights the foundational works, presentations, and writings of their creator, Steve Francia. These resources offer more than just technical instruction; they reveal the “why” behind the libraries’ design, showcasing their origins as practical solutions born from a passion for Go’s simplicity and power.

Foundational Works: The Source Code

The canonical source code repositories are the ultimate source of truth for both libraries. Their README files provide a concise yet comprehensive overview of their capabilities and are the best starting point for understanding their scope.

Cobra GitHub Repository

The primary resource for the Cobra library is its GitHub repository. Cobra is a library that provides a simple interface to create powerful modern CLI applications, similar in structure to git & go tools.

Key Features:

  • Easy subcommand-based CLIs (e.g., app server)
  • Fully POSIX-compliant flags
  • Nested subcommands
  • Intelligent suggestions for typos
  • Automatically generated help, shell autocompletion (for bash, zsh, fish, and powershell), and man pages

The core concepts are defined as a structure of Commands (actions), Args (things), and Flags (modifiers).

Viper GitHub Repository

The Viper library is presented as a complete configuration solution for Go applications. It is designed to handle all types of configuration needs and formats.

Core Capabilities:

  • Reading configuration from JSON, TOML, YAML, HCL, and .env files
  • Watching configuration files for live changes
  • Reading from environment variables and remote key/value stores like etcd or Consul
  • Binding to command-line flags

Cobra-CLI GitHub Repository

The cobra-cli tool is the official scaffolding program for Cobra applications. It is described as the easiest way to incorporate Cobra into an application, as it bootstraps the project scaffolding and generates command files. The generator simplifies development by creating a barebones project structure that can be run immediately, allowing developers to focus on editing the command logic rather than writing boilerplate code.

Presentations and Talks

These presentations provide a unique window into how the creator introduced and taught these libraries to the Go community.

“Building Your First Go App”

This key tutorial, delivered by Steve Francia, guides new Go developers through the practical experience of building a full-featured application from the ground up. Within this broader context of learning Go, the presentation introduces Cobra for creating the application’s CLI commands and Viper for managing its configuration.

It demonstrates how these libraries are used to build a working web and CLI application that interacts with a MongoDB backend. This presentation is a significant historical artifact, as it is often cited by community members as the talk that inspired them to adopt Cobra for their own projects.

Available Resources:

Writings and Philosophy

The following pieces offer personal reflections from Steve Francia, providing valuable context on the ethos that shaped Cobra and Viper.

Blog Post: “I’m joining Google to lead the Go language”

In this blog post, Steve Francia reflects on his journey with Go, stating that his passion for the language led directly to the creation of Hugo, Cobra, and Viper. He recounts his involvement in the early Go community, including speaking at the very first GopherCon and Gotham Go events.

This narrative humanizes the projects, framing them not as corporate products but as the results of a developer’s enthusiasm and deep community engagement.

Foreword: “Go Fundamentals Book”

Writing the foreword for the Gopher Guides book, Francia again looks back at the origins of his projects, noting that the first lines of code for Hugo, Cobra, and Viper were written over a decade ago. He expresses his hope that through learning Go, others will “fall in love with programming again,” the same feeling that motivated him.

This sentiment reinforces the idea that these libraries were designed to enhance the developer experience and align with the joyful simplicity that attracts so many to the Go language.

Next Steps

After exploring the creator’s foundational vision, continue your journey with: