-
But I don't think you can globally overwrite/shadow package methods the same way as in Python/JS/etc. It seems that you are looking for an AOP behavior and as far as I know there aren't many libraries for that in go (aspectgo is the first one that shows up, but it requires to run an additional command)
-
Stream
Stream - Scalable APIs for Chat, Feeds, Moderation, & Video. Stream helps developers build engaging apps that scale to millions with performant and flexible Chat, Feeds, Moderation, and Video APIs and SDKs powered by a global edge network and enterprise-grade infrastructure.
-
I use a clock interface, and for testing it's https://github.com/leononame/clock to simulate sleeps and timers and such if needed.
-
I discovered this lib a few days ago. https://github.com/bouk/monkey it allows you to monkey patch entire functions, replacing them by whatever you want. Perfect for mocking. It's simple to use. The program is hard patching the code using assembly to replace the function address at runtime. You should not use this lib out of your tests since it's absolutely not safe. It's only compatible with linux and windows. But it works great!