Skip to content

khaylebfortune/go-reloaded

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Reloaded

Go Reloaded is a command-line text processing tool I built in Go. It reads a file filled with inline flags like (hex), (cap, 6), or (up), interprets each one, and writes the corrected result to a new file. Think of it as a small but capable text editor that runs entirely from your terminal.

Building this was a satisfying puzzle — each transformation rule introduced its own set of edge cases, and figuring out how they interact with each other was the kind of challenge I enjoy most.


The Problem It Solves

Raw text often needs cleanup: numbers stuck in the wrong base, inconsistent casing, punctuation floating in the wrong place, articles that don't agree with the next word. Doing this manually is tedious. Go Reloaded handles all of it in one pass.

Before:

it (cap) was the best of times, it was the worst of times (up) , it was the age of foolishness (cap, 6) , IT WAS THE (low, 3) winter of despair.

After:

It was the best of times, it was the worst of TIMES, It Was The Age Of Foolishness, it was the winter of despair.

What It Handles

Number Conversions

Flag What it does Example
(hex) Hexadecimal → decimal "1E (hex) files""30 files"
(bin) Binary → decimal "10 (bin) years""2 years"

Case Modifications

Flag What it does Example
(up) Uppercase 1 word "go (up)""GO"
(low) Lowercase 1 word "SHOUTING (low)""shouting"
(cap) Capitalize 1 word "bridge (cap)""Bridge"
(up, N) Uppercase N words "so exciting (up, 2)""SO EXCITING"

Punctuation & Formatting

Rule Before After
Attach to previous word "hello ,world" "hello, world"
Group punctuation "thinking ... You" "thinking... You"
Quote cleanup "' awesome '" "'awesome'"
Article correction "a amazing rock" "an amazing rock"

Getting Started

Prerequisites

You'll need Go 1.22+ installed. Verify with:

go version

Setup

git clone https://acad.learn2earn.ng/git/cmoses/go-reloaded.git
cd go-reloaded

Run It

go run . sample.txt result.txt
cat result.txt

That's it. Input goes in, clean text comes out.


Project Structure

go-reloaded/
├── go.mod          — Module definition
├── main.go         — Entry point: reads input, runs the pipeline, writes output
├── functions.go    — All five transformation functions
├── sample.txt      — Sample input for testing
└── result.txt      — Program output

I kept the structure lean on purpose — two Go files, one for orchestration and one for logic. Everything lives in functions.go organized into five clearly labeled sections.


Under the Hood

The core of the program is a pipeline in processText() that chains five functions together. Each one takes in text, applies its transformation, and passes the result to the next:

Raw text
  → applyHexBin()    — number base conversions
  → applyCase()      — uppercase, lowercase, capitalize
  → fixPunctuation() — spacing around . , ! ? : ;
  → fixQuotes()      — spacing inside ' ... ' pairs
  → fixArticles()    — "a" → "an" before vowels/h
  → Clean text

The order is intentional. Numbers get converted first so they don't interfere with text formatting. Articles run last because earlier transformations might change which words end up where.

The trickiest part was applyCase — it processes flags one at a time (leftmost first) because each flag modifies the words before it. Replacing all flags at once would shift positions and corrupt the results. Getting that right was a good reminder that order of operations matters just as much in text processing as it does in math.


What I Took Away

This project reinforced something I already believed — the best way to understand a language is to solve real problems with it. Working through the edge cases here (nested punctuation groups, whitespace preservation, greedy vs. non-greedy regex) taught me more about Go's regexp, strconv, strings, and unicode packages than any tutorial could.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages