Member-only story

Building a CLI App in Golang with a day

Girff
7 min readDec 7, 2024

--

I recently moved back into a full-time mobile developer role at a company I admire, which means that I don’t write Golang as much anymore. I needed to keep up with Golang, but I needed something more glamorous than writing simple CRUD applications, and here we are!

CLI apps, Command-line applications, are applications that are run from the command line. This is normally done via a terminal depending on the operating system of choice. Golang is a great choice for building command-line applications because it compiles to a single binary with no external dependencies, so you can distribute CLI tools without worrying about dependency management on the target machine.

I had an idea in mind and set out to build a CLI app to help with that. I learned about the Cobra and Charm libraries used to create and glamourize CLI interfaces. In this article, you will too. We will be building a CLI application that will provide terminal command suggestions to our users based on a prompt they enter.

Setup

You need to have Golang installed on your device. You can follow the steps here. You also need an understanding of Golang or the general syntax of programming languages. Let’s move on.

Cobra

Cobra is a Golang library that provides a simple API to create powerful modern CLI interfaces similar to git & go tools. This library provides easy subcommand-based CLIs, nested subcommands, global, local, and cascading flags, and a host of…

--

--

No responses yet