Introduction I’ve officially completed my first significant project in Go! As I transition into software engineering, I’m realizing that coding is very similar to designing a building: you need a solid foundation (logic) and attention to detail (syntax).
This project is a Text Completion tool. The goal was to build a program that reads a text file containing raw data and specific "formatting commands" (like (hex), (up), or (cap)), processes them, and outputs a clean, grammatically correct sentence.
Here is what I built and what I learned along the way.
The Challenge The program needed to take an input file like this: "1E (hex) files were found in the folder (up)"
And turn it into this: "30 FILES were found in the folder"
It had to handle:
Conversions: Hexadecimal and Binary to Decimal.
Transformations: Uppercase, Lowercase, and Capitalization.
Grammar: Fixing punctuation spacing and correcting "a" to "an" before vowels.
How I Structured the Logic The core of the program is the applyCommands function. It iterates through the words (slices of strings) and looks for specific tags.
One of the most interesting challenges was handling the index manipulation. When a command like (hex) is found, it affects the previous word. I had to convert that word, and then remove the command itself from the slice so it doesn't appear in the final text.
The Power of Regular Expressions (Regexp) Once the words were processed, I had to fix the punctuation. I learned that doing this manually with if/else statements is messy. This was my introduction to the regexp package.
I created a function called fixPuncAndVowels. It uses patterns to ensure punctuation sticks to the previous word but has a space after it.
This single line of code replaced almost 20 lines of complex loop logic I had written initially!
What I Learned
Slice Manipulation: I learned that when you remove an item from a slice in Go, you have to be very careful with your index (i--) so you don't skip the next word.
Type Conversion: Moving between strings, integers, and back to strings using strconv.
Modular Code: Breaking the code into small functions like hexToDec and capitalize made debugging much easier.
Conclusion This project taught me that coding isn't just about syntax; it's about breaking a large problem into small, solvable logical steps. I’m excited to keep building and exploring more complex architectures in Go.


Top comments (0)