Show HN: Simple Go mocks without interface{}s

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

CodeRabbit: AI Code Reviews for Developers
Revolutionize your code reviews with AI. CodeRabbit offers PR summaries, code walkthroughs, 1-click suggestions, and AST-based analysis. Boost productivity and code quality across all major languages with each PR.
coderabbit.ai
featured
InfluxDB high-performance time series database
Collect, organize, and act on massive volumes of high-resolution data to power real-time intelligent systems.
influxdata.com
featured
  1. go-mocky

    Type safe mock generator in Go

  2. CodeRabbit

    CodeRabbit: AI Code Reviews for Developers. Revolutionize your code reviews with AI. CodeRabbit offers PR summaries, code walkthroughs, 1-click suggestions, and AST-based analysis. Boost productivity and code quality across all major languages with each PR.

    CodeRabbit logo
  3. mockery

    A mock code autogenerator for Go (by vektra)

    Since mockery uses a lot of interface{} magic, adding arguments or return values to interfaces and regenerating the mocks does not get the compiler to complain about existing, now invalid, usages of the mocks. This means that I have to track them down manually. Or, if I'm brave enough, try my hand at a few crazy regexes that never get the job 100% done.

    go-mocky does not use interface{}s, and thus can't hide changes to function signatures from the compiler; whenever a mock has been updated and the function signature has changed, the compiler will complain for all existing tests. This means that I can now catch errors at compile/lint time instead of runtime.

    Another added benefit is that the go-mocky mocks are dead simple and very easy to write and maintain by hand, should the need ever arise.

    [1]: https://github.com/vektra/mockery

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

  • I Write Tests in Go

    1 project | news.ycombinator.com | 10 Apr 2024
  • Direction of mockery: absorb different styles of mocks into this project · vektra mockery · Discussion #671

    1 project | /r/golang | 11 Jul 2023
  • Go: Write Mock Test cases using Mockery and

    1 project | dev.to | 10 May 2023
  • Mocking unexported interfaces?

    1 project | /r/golang | 28 Apr 2023
  • vektra/mockery: v2.21.0 includes "packages" config section, allowing 5x faster mock generation and more fine-grained control over mocks

    1 project | /r/golang | 4 Mar 2023

Did you know that Go is
the 4th most popular programming language
based on number of references?