Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Building Modern CLI Applications in Go

You're reading from   Building Modern CLI Applications in Go Develop next-level CLIs to improve user experience, increase platform usage, and maximize production

Arrow left icon
Product type Paperback
Published in Mar 2023
Publisher Packt
ISBN-13 9781804611654
Length 406 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Marian Montagnino Marian Montagnino
Author Profile Icon Marian Montagnino
Marian Montagnino
Arrow right icon
View More author details
Toc

Table of Contents (21) Chapters Close

Preface 1. Part 1: Getting Started with a Solid Foundation
2. Chapter 1: Understanding CLI Standards FREE CHAPTER 3. Chapter 2: Structuring Go Code for CLI Applications 4. Chapter 3: Building an Audio Metadata CLI 5. Chapter 4: Popular Frameworks for Building CLIs 6. Part 2: The Ins and Outs of a CLI
7. Chapter 5: Defining the Command-Line Process 8. Chapter 6: Calling External Processes and Handling Errors and Timeouts 9. Chapter 7: Developing for Different Platforms 10. Part 3: Interactivity and Empathic Driven Design
11. Chapter 8: Building for Humans versus Machines 12. Chapter 9: The Empathic Side of Development 13. Chapter 10: Interactivity with Prompts and Terminal Dashboards 14. Part 4: Building and Distributing for Different Platforms
15. Chapter 11: Custom Builds and Testing CLI Commands 16. Chapter 12: Cross-Compilation across Different Platforms 17. Chapter 13: Using Containers for Distribution 18. Chapter 14: Publishing Your Go Binary as a Homebrew Formula with GoReleaser 19. Index 20. Other Books You May Enjoy

Go for CLIs

The very same overarching reasons I suggest engineers learn Go are the very same reasons I suggest using Go to build your CLI, but the very history of modern CLIs, which began in the 1960s with the UNIX shell, invented at Bell Labs by Ken Thompson, co-inventor of Golang, holds much weight. The UNIX philosophy, which inspires our modern CLI philosophy and guidelines, is built into the language, and it’s clear that many benefits have been born out of this way of thinking:

  • Performance, scalability, and power

Golang is quite fast in its compilation and execution. For example, Kubernetes, which is written in Go, has 5 million lines of application code that compile within a couple of minutes. Any other language would take 10 minutes to several hours to compile. Go translates its source code to machine code within its own optimized compiler, allowing easier dependency management. Also, because Golang is still a young language, it’s built for contemporary hardware requirements.

Goroutines are lightweight threads that run concurrently. In my experience programming, I have not seen simplicity and multi-threading go hand in hand, but Golang achieves this extremely well. This feature won my heart.

The performance and scalability of Go are an obvious draw to the cloud computing community. Many CLIs for cloud computing were written in Go, Docker and Kubernetes included. Any application with a growing user base or a high number of traffic requests needs to consider Golang. Companies such as Uber and Comcast have chosen Go for this reason as well.

  • Simplification of development

Golang felt easier to learn than any other language I’ve ever encountered. The language supports a clean, simple, and fast environment, which is impressive, considering the powerful tools that Go has created. Golang also has many tools that allow the speed and accuracy of development, including formatting tools, testing frameworks, a great linter, and tools to perform static analysis.

  • Versatility

Go makes cross-compilation so easy. You can build your application for many different OSs and architectures, increasing accessibility to your CLI. Although executing within different environments, if properly configured, it will work similarly. This will ease users’ minds. Later on in this book, we will discuss how to create binaries for different platforms.

  • Growing your skillset

Golang is among the most popular languages to learn. Given its many apparent benefits, more start-ups and enterprises are choosing Golang and the demand for Golang developers is growing.

  • Community

If you choose Go, you’ll be a part of a community of enthusiastic open source developers, willing to partake in the evolutionary journey of a young programming language.

For beginners who are building a CLI in Go for the first time, the next chapters ahead show how clear it is. Golang is an excellent choice for building a CLI, and when there’s a need for scalability, performance, and cross compilation, the choice will play in your favor.

You have been reading a chapter from
Building Modern CLI Applications in Go
Published in: Mar 2023
Publisher: Packt
ISBN-13: 9781804611654
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image