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

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

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.
getstream.io
featured
InfluxDB – Built for High-Performance Time Series Workloads
InfluxDB 3 OSS is now GA. Transform, enrich, and act on time series data directly in the database. Automate critical tasks and eliminate the need to move data externally. Download now.
www.influxdata.com
featured
  1. 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)

  2. 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.

    Stream logo
  3. clock

    Time mocking library for golang (by leononame)

    I use a clock interface, and for testing it's https://github.com/leononame/clock to simulate sleeps and timers and such if needed.

  4. monkey

    Discontinued Monkey patching in Go (by bouk)

    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!

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

  • Testing HTTP Requests with http.RoundTripper

    1 project | dev.to | 4 Jul 2025
  • 🧪 Uber Mock: El sucesor natural de GoMock que deberías conocer

    1 project | dev.to | 7 Jun 2025
  • The best way for testing outbound API calls

    6 projects | dev.to | 6 Feb 2025
  • Testando chamadas para APIs da melhor forma

    7 projects | dev.to | 6 Feb 2025
  • Testando código que chama serviços da AWS

    4 projects | dev.to | 4 Feb 2025