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.

Monkey Patching in Golang (2015)

72 pointsby donutloopover 5 years ago

6 comments

rodrigobritoover 5 years ago
Read the license before use the library: <a href="https:&#x2F;&#x2F;github.com&#x2F;bouk&#x2F;monkey&#x2F;blob&#x2F;master&#x2F;LICENSE.md" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;bouk&#x2F;monkey&#x2F;blob&#x2F;master&#x2F;LICENSE.md</a> Caution! This approach is very dangerous, and not thread safe.
评论 #22442608 未加载
评论 #22442567 未加载
评论 #22442855 未加载
评论 #22488721 未加载
评论 #22442578 未加载
pjmlpover 5 years ago
Cool to see these system level programming tricks being done in Go.<p>This kind of dirty tricks is sometimes used to mock binary libraries for testing.<p><a href="https:&#x2F;&#x2F;www.microsoft.com&#x2F;en-us&#x2F;research&#x2F;project&#x2F;detours&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.microsoft.com&#x2F;en-us&#x2F;research&#x2F;project&#x2F;detours&#x2F;</a><p><a href="https:&#x2F;&#x2F;docs.microsoft.com&#x2F;en-us&#x2F;visualstudio&#x2F;test&#x2F;isolating-code-under-test-with-microsoft-fakes?view=vs-2019" rel="nofollow">https:&#x2F;&#x2F;docs.microsoft.com&#x2F;en-us&#x2F;visualstudio&#x2F;test&#x2F;isolating...</a><p>Yep, questionable, but sometimes that is the only way to match those QA metrics.
评论 #22443035 未加载
callmealover 5 years ago
Hah reminds me of the spirit of fuckitjs (<a href="https:&#x2F;&#x2F;github.com&#x2F;mattdiamond&#x2F;fuckitjs" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mattdiamond&#x2F;fuckitjs</a>).
seanwilsonover 5 years ago
What are some good uses of monkey patching? How do you stop it being a maintenance nightmare?
评论 #22444427 未加载
meddlepalover 5 years ago
Hmm could be an interesting way to decorate funcs with logging.
评论 #22442747 未加载
laumarsover 5 years ago
This is from 2015 (though I didn&#x27;t see it that time round so thanks for the resubmission).<p>Previous discussion: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=9290917" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=9290917</a>