Skip to content
This is my space, where experience meets the will to start over. This is my space, where experience meets the will to start over.

The first step is knowing where you want to go.

  • Home
  • Coding Hub
    • Software & Project
      • Small Biz Ops – S.B.O.
        • SmallBizOps – Day 10/90
      • CRM/ERP
      • MyTracker
      • My Budget
    • Form Zero to “WoW”
      • JavaScript from Zero (Completed)
        • 2. Remove and Edit List Items
        • 3. Separate HTML and JavaScript, Use addEventListener and Conditional Logic
        • 4. Add Dynamic CSS Classes
        • 5. Save & Restore Your List with localStorage
        • 6 – Turn Your App into a Full To-Do List
      • Python from Zero (Completed)
        • 2. Lists & Loops
        • 3. Conditional Menus
        • 4. Edit & Remove Tasks (with closing: Python vs PHP and Large Data)
        • 5 – Save to File: Make Your Tasks Survive Restarts
        • 6 — Pythin from zero – Final Project Polishing: Numbering, Formatting, and Preparing for CSV
      • Rust – From Zero to “WoW” (Completed)
        • 1 – Setup and Project Structure in Rust
        • 2 – User input: validation and error handling
        • 3 – Rust from Zero to “WoW – BMI Calculation and Conditional Logic
        • 4 –Rust – Clear, Formatted Output
        • 5 – Rust – Final Thoughts: Precision as a Form of Respect
      • Go from Zero to “WoW” (Completed)
        • 1 – Why Go Is Perfect for a Personal Expense Tracker
        • 2 – Logging Expenses and Console Input
        • 3 – Go from Zero to “WoW” – Smart Filtering & Display Logic
        • 4 – Go – Saving Data to Local Files
        • 5 – Go – Final Project – Expense Tracker in Go
      • C++ from Zero to “WoW” (Completed)
        • 1 – Why C++ for file organization?
        • 2 – C++ – File Type Detection and Classification
        • 3 – C++ – Creating & Managing Subfolders
        • 4 – C++ – Safe File Movement and User Feedback
        • 5 – C++ – Order as Mental Clarity
      • Ubuntu – From Zero to “WoW” (Completed)
        • 2 – Ubuntu – The Desktop Environment and Essential Commands
        • 3 – Ubuntu – Managing Files, Folders, and Permissions
        • 4 – Ubuntu – Installing and Updating Software with APT and Snap
        • 5 – Ubuntu – Customizing the Desktop Environment
        • 6 – Ubuntu – Network and Device Configuration
        • 7 – Ubuntu – User Management & System Security — “The Cathedral of Permissions”
        • 8 – Ubuntu – The Talking Machine: Terminal & Bash Scripting
        • 9 – Ubuntu – Ubuntu as a Server or Development Environment
        • 10 – Ubuntu – Backup, Maintenance & Troubleshooting
    • Git Hub Repository
      • Small Biz Ops – S.B.O.
      • Mini ERP – PHP & MySQL
      • CleverCRM (Java, Spring Boot)
      • FraudWatch (Python, FastAPI + scikit-learn)
      • OnboardIQ – Smart Onboarding Portal (Flask + SQLite Demo)
    • ArchPilot
      • 1-Users & Roles, End-to-End (Architecture, Database, and Cross-Framework Code)
      • 2 – Client Registry (CRM) Across Frameworks
      • 3 – Project & Budget Tracker (ERP)
      • 4 – Approval Workflow Engine Multi-step routing, status tracking, escalation paths
      • 5 – Audit Trail & Versioning
    • Small Biz Ops – S.B.O.
  • Vivere in USA
  • P4Y
  • Testi poetici
    • 1 – Sospeso
    • 2 – Il bicchiere di vetro quieto
    • 3 – Quando l’amore inciampa
    • 4 – Ma chi siete davvero?
    • 5 – Above the Thread of Day
    • 6 – The Truth That Doesn’t Exist
    • 7 – All of You, I Miss
    • 8 – The Captain and the Ocean
    • 9 – Between Light and Mist
    • 10 – Il peso delle scelte
  • Contact
  • Admin
This is my space, where experience meets the will to start over.
This is my space, where experience meets the will to start over.

The first step is knowing where you want to go.

Coding – Step 12.5 – GO – Final Project – Expense Tracker in Go

Posted on 18 Ottobre 202518 Ottobre 2025 By Francesco

Conclusion: Simplicity That Improves Life

Introduction

Throughout this course, you’ve learned how Go handles logic, structure, and performance with minimalism and clarity. Now, we close with a project that embodies the Go philosophy: simple tools that make life easier.

This final project is a local expense tracker. It doesn’t rely on databases or cloud services. It’s fast, lightweight, and respectful of your data. It saves your expenses in a local file (CSV or JSON), and gives you a clean summary of your spending.

Goal

Create a command-line tool in Go that:

  • Accepts expense entries (date, category, amount, description)
  • Saves them to a local file (CSV or JSON)
  • Displays a summary of total spending per category
  • Keeps the code readable, maintainable, and beginner-friendly

Project Structure

1. Data Model

type Expense struct {
    Date        string  `json:"date"`
    Category    string  `json:"category"`
    Amount      float64 `json:"amount"`
    Description string  `json:"description"`
}

2. Input Function

func getExpenseInput() Expense {
    reader := bufio.NewReader(os.Stdin)

    fmt.Print("Date (YYYY-MM-DD): ")
    date, _ := reader.ReadString('\n')

    fmt.Print("Category: ")
    category, _ := reader.ReadString('\n')

    fmt.Print("Amount: ")
    var amount float64
    fmt.Scanf("%f\n", &amount)

    fmt.Print("Description: ")
    description, _ := reader.ReadString('\n')

    return Expense{
        Date:        strings.TrimSpace(date),
        Category:    strings.TrimSpace(category),
        Amount:      amount,
        Description: strings.TrimSpace(description),
    }
}

3. Save to File (CSV or JSON)

func saveExpenseCSV(exp Expense, filename string) {
    file, err := os.OpenFile(filename, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
    if err != nil {
        log.Fatal(err)
    }
    defer file.Close()

    writer := csv.NewWriter(file)
    defer writer.Flush()

    record := []string{exp.Date, exp.Category, fmt.Sprintf("%.2f", exp.Amount), exp.Description}
    writer.Write(record)
}

func saveExpenseJSON(exp Expense, filename string) {
    var expenses []Expense

    data, err := os.ReadFile(filename)
    if err == nil {
        json.Unmarshal(data, &expenses)
    }

    expenses = append(expenses, exp)

    updatedData, _ := json.MarshalIndent(expenses, "", "  ")
    os.WriteFile(filename, updatedData, 0644)
}

4. Summary Function

func showSummary(filename string) {
    data, err := os.ReadFile(filename)
    if err != nil {
        log.Fatal(err)
    }

    var expenses []Expense
    json.Unmarshal(data, &expenses)

    summary := make(map[string]float64)
    for _, exp := range expenses {
        summary[exp.Category] += exp.Amount
    }

    fmt.Println("\nSpending Summary:")
    for cat, total := range summary {
        fmt.Printf("- %s: $%.2f\n", cat, total)
    }
}

5. Main Function

func main() {
    filename := "expenses.json"
    exp := getExpenseInput()
    saveExpenseJSON(exp, filename)
    showSummary(filename)
}

What You’ve Learned

  • How to structure a Go program with clarity
  • How to read user input and validate it
  • How to save structured data to local files
  • How to summarize and display useful insights
  • How simplicity can be powerful when done right

Why “Simplicity That Improves Life”?

Because tools don’t need to be complex to be helpful. This project doesn’t use databases, servers, or frameworks. It’s just Go, files, and logic. And yet, it solves a real problem—tracking your spending—with elegance and speed.

What’s Next?

  • Add support for CSV export
  • Build a web interface with Go + HTMX
  • Add filters by date or category
  • Create a monthly report generator
  • Package it as a CLI tool with flags (cobra or urfave/cli)

Thank You

Thank you for walking through this course. I hope you’ve discovered that Go isn’t just fast—it’s freeing. And that simplicity, when done well, is a form of respect.

Disclaimer

This project is for educational purposes only. It does not include encryption, authentication, or cloud backup. Use responsibly and do not store sensitive financial data without proper safeguards.

Post Views: 351

Condividi:

  • Condividi su Facebook (Si apre in una nuova finestra) Facebook
  • Condividi su X (Si apre in una nuova finestra) X
Coding Form Zero to "WoW" Go beginnerCSVdata-persistenceexpense-trackerfile-iofinal-projectGojsonminimalismsimplicitywow-factor

Navigazione articoli

Previous post
Next post

Francesco

My name is Francesco Boschi, originally from Italy and currently based in the United States. For over twenty years, I’ve worked as a manager and consultant across diverse sectors — from education and cultural institutions to the food industry — developing skills in operational management, strategic consulting, and complex problem-solving. In recent years, I’ve combined this experience with a strong passion for software development, creating custom tools designed to simplify workflows and meet real business needs.

Relocating to the U.S. marks the beginning of a new chapter: a personal and professional decision driven by the desire to be close to my son and to embrace new challenges in a different environment. Today, my goal is to turn my experience into meaningful solutions, blending strategic vision with technical expertise to help people and organizations work more effectively.

I enjoy moving between different worlds, adapting tools and approaches to people and contexts. I bring leadership, flexibility, attention to detail, analytical thinking, and a strong problem-solving mindset — along with a deep curiosity to learn and grow. Above all, I believe in sharing: I’m always eager to offer my experience to support the growth of others.

Related Posts

C++

Coding – Step 13.2 – C++ from Zero to “WoW” – File Type Detection and Classification

Posted on 27 Settembre 202527 Settembre 2025

Learn how to detect file types and automatically organize them into categories with C++17. This beginner-friendly guide uses the library to classify files by extension and move them into the right folders step by step.

Condividi:

  • Condividi su Facebook (Si apre in una nuova finestra) Facebook
  • Condividi su X (Si apre in una nuova finestra) X
Read More
Python

Coding – Step 10 – Python from Zero – Lesson 1: Variables, Input, and Simple Logic

Posted on 28 Luglio 202523 Agosto 2025

Welcome to the first real Python lesson — where you’ll build a mini console app using real code, logic, and user input. No theory-only content here: we learn by writing and running code immediately. 📚 What You’ll Learn ✅ How to use print() and input()✅ How to store and use…

Condividi:

  • Condividi su Facebook (Si apre in una nuova finestra) Facebook
  • Condividi su X (Si apre in una nuova finestra) X
Read More
Go

Coding – Step 12 – Go from Zero to “WoW”

Posted on 5 Settembre 202527 Settembre 2025

A fast and pragmatic expense tracker built in Go, designed for everyday use. Log your spending, filter by category, and save locally — no cloud, no clutter. A perfect example of how simplicity and speed can solve real-life problems.

Condividi:

  • Condividi su Facebook (Si apre in una nuova finestra) Facebook
  • Condividi su X (Si apre in una nuova finestra) X
Read More

Iscriviti alla nostra Newsletter

🤞 Let's keep in touch

We do not send spam! Read our Privacy policy for more information.

Controlla la tua casella di posta o la cartella spam per confermare la tua iscrizione

Cerca nel sito

©2026 This is my space, where experience meets the will to start over. | WordPress Theme by SuperbThemes