Snag

I wrote Snag last year around November, but it was not mature enough to be used as an alternative to existing hot reloaders, as I was just learning Go back then and unable to integrate goroutines. Now that I have gained more experience and understand how to write idiomatic Go, I’m ready to rewrite it to make it more scalable and testable.

Hello geeks, this is Utkarsh. I’m a Go developer and I love writing Go code.

Today, we’ll talk about my idea of integrating inotify with goroutines to build a fast and flexible hot reloader. I originally came up with this idea about a year ago, but due to a lack of understanding of Linux subsystems and concurrency in Go, I decided to postpone the implementation until I became comfortable with goroutines.

So here I am, starting to rewrite Snag from the ground up.

Wed, Dec 17

Today, I designed and implemented dependency injection around the cobra CLI to make the project more flexible, testable, and scalable. My initial intention was to improve security, particularly to guard against SQL injection, so I experimented with this approach.

I’m not entirely sure whether this is the best solution yet, but that’s part of the process. We’ll figure it out as we move forward with Snag. That’s all the progress I made today.

Thu, Dec 18

Today, I wrapped the logger in an interface and injected it into the main application. I learned an important concept of dependency injection (DI): it is based on behavior rather than implementation.

I also want to clarify that I was wrong in thinking that DI prevents SQL injection. Dependency injection is simply a way to introduce different dependencies without exposing their actual implementations.

Tue, Dec 23

Today, I finally understood how to manage configuration files using viper, and I’m genuinely glad that I decided to rewrite this project. As I move forward, I keep learning many crucial aspects of programming that I had previously overlooked.

I also realized something important, something many coders don’t fully understand. The evolution from coder to programmer happens only when a person recognizes the difference between simply writing code and truly programming. That difference lies in following the idioms and conventions of the language you are using.

No programming language is perfect for every problem. To get the most out of a language, you need to respect its design principles and follow its rules. When you do that, the magic really begins to happen.