mtnr

A tech blog with fries on the side

Tag: go

  • Building My First CLI Tool in Go: A TODO Manager

    I decided to get acquainted with Go by building something practical: a command-line TODO manager. No better way to understand a language than to build a real tool with it.

    What I Built

    todo-cli is a simple, lightweight TODO list manager that runs entirely in your terminal. It stores your tasks locally in JSON format and supports all the essential operations you’d expect:

    • Add new tasks
    • List active, completed, or all tasks
    • Mark tasks as complete
    • Delete tasks you no longer need

    Everything is stored in ~/.todo-cli/todos.json, so your data stays local and under your control.

    Why Go?

    Go’s reputation for simplicity and its dominance in the CLI tool space made it an obvious choice. Tools like Docker, Kubernetes, and Hugo are all written in Go, and I wanted to understand why.

    The experience was refreshing. Go’s straightforward syntax, built-in tooling, and focus on pragmatism over abstraction made it easy to get productive quickly. No build tools to configure, no frameworks to choose between—just go build and you’re done.

    What I Learned

    This weekend project taught me:

    • Go fundamentals: structs, interfaces, methods, and error handling
    • CLI development with Cobra
    • Go’s approach to project structure and package organization
    • Testing patterns in Go
    • Working with JSON marshaling and file I/O

    The interface-based storage design means I can easily swap out JSON for SQLite or another backend later if needed.

    Quick Example

    bash

    # Add some tasks
    $ todo-cli add "Review pull requests"
    ✓ Added todo #1: Review pull requests
    
    $ todo-cli add "Write blog post"
    ✓ Added todo #2: Write blog post
    
    # See what's on your plate
    $ todo-cli list
    Active TODOs:
    
    ☐ [1] Review pull requests (created: Feb 8, 2026)
    ☐ [2] Write blog post (created: Feb 8, 2026)
    
    # Mark one complete
    $ todo-cli complete 2
    ✓ Completed todo #2: Write blog post

    Try It Yourself

    The project is open source under the MIT license and available on Codeberg. If you’re interested in learning Go, building a CLI tool is a great first project—it’s practical, achievable in a weekend, and teaches you the fundamentals without getting bogged down in web frameworks or complex architectures.

    Happy coding!