is there an easy (python like way) to do mocks?

This page summarizes the projects mentioned and recommended in the original post on

Our great sponsors
  • Scout APM - Less time debugging, more time building
  • SonarQube - Static code analysis for 29 languages.
  • OPS - Build and Run Open Source Unikernels
  • GitHub repo aspectgo

    Aspect-Oriented Programming framework for Go

    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)

  • GitHub repo clock

    Time mocking library for golang (by leononame)

    I use a clock interface, and for testing it's to simulate sleeps and timers and such if needed.

  • Scout APM

    Less time debugging, more time building. Scout APM allows you to find and fix performance issues with no hassle. Now with error monitoring and external services monitoring, Scout is a developer's best friend when it comes to application development.

  • GitHub repo monkey

    Monkey patching in Go (by bouk)

    I discovered this lib a few days ago. 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!

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts