Powerful Command-Line Applications in Go
408 pages
English
PDF
4.5

Powerful Command-Line Applications in Go

Powerful Command-Line Applications in Go

Author:

Year:

Summary:

Introduction

The book "Powerful Command-Line Applications in Go" by Ricardo Gerardi was published in 2021 and immediately attracted the attention of developers working with the Go language. This is not another introduction to syntax — it is a practical guide to creating professional, reliable, and maintainable command-line tools. In a world where CLI utilities remain the foundation of DevOps, administration, and automation, the book fills an important niche: how to write not just working, but industrial-grade console applications.

What the book is about

The book is built around the development of a real project — a task management utility (todo manager) that gradually becomes more complex from chapter to chapter. The author consistently guides the reader through all stages: from setting up the environment and basic input/output to advanced topics such as OS signal handling, working with the file system, configuration files, testing, and build automation.

Special attention is given to:

  • Code structuring and package organization;
  • Error handling and graceful shutdown;
  • Integration with external APIs and databases;
  • Writing tests (unit, integration, end-to-end);
  • Building and distributing binary files via CI/CD.

Who this book is for

The book is intended for developers already familiar with the basics of Go. If you can write simple programs in Go but want to move to the next level — creating tools that other people will use — this book is for you. It will also be useful for DevOps engineers, system administrators, and anyone who wants to automate routine tasks using Go.

What the reader will learn

  • CLI application design: how to properly organize code so that it is easy to extend and maintain.
  • Working with arguments and flags: using the standard flag package and alternatives (e.g., cobra).
  • Input/Output: reading from stdin, writing to stdout/stderr, working with files and pipes.
  • Configuration: loading settings from environment variables, files (JSON, YAML, TOML) and their prioritization.
  • Signal handling: graceful shutdown upon receiving SIGINT/SIGTERM.
  • Testing: writing tests for CLI applications, mocking the file system and external services.
  • CI/CD: automatic building, testing, and publishing binary files for different platforms.
  • Performance: profiling, benchmarks, and optimization.

Strengths

The main advantage of the book is its practical focus. Each chapter contains ready-to-run code that can be immediately executed and modified. The author doesn't just explain theory but shows how to apply it in a real project.

The second plus is relevance. The book uses modern versions of Go (1.16+) and covers tools that are actively used in the industry: Cobra, Viper, Testify, GitHub Actions.

The third point is structure. The material is presented on the principle of "from simple to complex," but without fluff. Each chapter ends with exercises for reinforcement.

Finally, the book teaches good practices: writing tests, error handling, code documentation. This makes it useful not only for learning CLI but also for the overall skill improvement of a Go developer.

Who it is recommended for

I recommend this book to anyone who wants to learn how to create professional console utilities in Go. It will be useful both for beginners who have already mastered the basics of the language and for experienced developers who want to systematize their knowledge of CLI development. The book will be especially useful for those working in DevOps, SRE, or infrastructure automation.

If you write scripts in Bash or Python and want to move to a more pro

Recommendations