TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: Simple Go mocks without interface{}s

1 pointsby micvbangalmost 3 years ago
I&#x27;ve been a pretty happy user of mockery [1] for a while, but recently found it getting a lot in my way. 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&#x27;m brave enough, try my hand at a few crazy regexes that never get the job 100% done.<p>go-mocky does not use interface{}s, and thus can&#x27;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&#x2F;lint time instead of runtime.<p>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.<p>[1]: <a href="https:&#x2F;&#x2F;github.com&#x2F;vektra&#x2F;mockery" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;vektra&#x2F;mockery</a>

no comments

no comments