Posts

Cpp Tricks Defer

One of my favorite uses for defer in Go is when a function has multiple return paths, but you still need to run the same handful of instructions before exiting. Instead of writing complicated logic to handle this, a simple defer goes a long way.

I have missed this functionality a lot in C++, but I’ve found a way to use destructors to accomplish the same. It’s not exactly the same as defer, but it’s a good workaround that brings some of the simplicity I appreciate from Go into my C++ code.

Interfacor

Streamlining MMI/Console Interface Development with Go

In the realm of engineering, early career experiences can significantly shape our problem-solving skills and technical approaches. Reflecting on my journey, the lessons learned from my first boss in engineering continue to influence my work, even two decades later. His unique perspective on tackling challenges and implementing solutions has been invaluable.

I started as an embedded engineer, working on 8 bit micros. A key component and accelerator on every project was the Man Machine Interface (MMI), essentially a dynamic and efficient terminal/console interface for these devices. This approach not only simplified implementation but also enhanced our ability to scale and adapt projects over time.

Future Refference

I am just putting this piece of code here for future reference because I keep needing to rewrite or Google for it.

It is a “simple” way to get terminal key presses in Linux-based systems.

making Configuration boring in Go with Constructor

While the 12 Factor App advocates for using environment variables in configuration, I felt the need for a more comprehensive solution. This realization prompted the creation of Constructor, a lightweight Go library/module. Its purpose is to streamline the configuration process by simplifying structs through tags, default values, and support for overrides from YAML files, environment variables, and flags.

In summary, Constructor is designed to elevate the configuration experience in Go, providing an efficient and versatile solution to eliminate repetitive tasks across various applications.