Original post

In one of my projects, I needed a way to override one of the methods in a struct with a mock to simplify testing, but unfortunately, Go doesn’t support OO-style interface with inheritance and overrides as I’ve been accustomed to in other languages such as C++ and Java.

I ended up with a mechanism to enable such overrides and wrote a blog post, and several folks let me know it solved similar problems that they were facing, so I wanted to share it with the community to see if it would be useful for others as well. There’s complete sample code included in the post to illustrate the use case.

Let me know what you think and if you find it useful! If you know of an easier way of accomplishing this, I’d love to hear about it.

Thanks!