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.

The Adapter Pattern in Go

18 pointsby gus_leonelalmost 2 years ago

5 comments

vasachialmost 2 years ago
Honestly, just use a real db in testing. Purity is all well and good, but not at the expense of more bugs caught.
评论 #36891291 未加载
评论 #36891839 未加载
评论 #36891435 未加载
评论 #36891566 未加载
评论 #36892026 未加载
usrnmalmost 2 years ago
The problem with this approach in practice is that the abstraction tends to leak real fast. One day you'll need to hack something ugly to fix a performance issue in prod or whatever and it all will come crashing down.
erik_seabergalmost 2 years ago
If you want to mock a database to have a fast subset of tests, first test the client the hard way and prove you’re using the real database correctly (not just asserting what you hope it would do).
marcus_holmesalmost 2 years ago
Any ideas how you test the SQL using this approach?
评论 #36892024 未加载
评论 #36893933 未加载
dontlaughalmost 2 years ago
Besides mocks hiding subtle bugs, the adapter approach can very easily hide costs. This is how you end up with O(n) SQL queries.
评论 #36891723 未加载