Home
Sign Up
Sign In
爱意满满的作品展示区。
Advertisement
V2EX
›
分享创造
自动生成 Go 的“代理类(struct)”
roy2220
·
Jun 16, 2020
· 3574 views
This topic created in 2346 days ago, the information mentioned may be changed or developed.
撸了个 Go 的“代理类”生成器,自动分析 struct 、interface 的所有方法(支持嵌套结构),生成一个 proxy struct,可以通过这个 proxy struct 拦截各种方法调用,修改调用参数、返回值等,需要自取 =>
https://github.com/roy2220/proxyz
struct
proxy
调用
返回值
4 replies
•
2020-06-21 11:22:10 +08:00
wfhtqp
Jun 17, 2020
1
画蛇添足
cc100
Jun 17, 2020
2
这个代理是为了解决什么问题呢
roy2220
OP
Jun 17, 2020
3
@
cc100
常见就是 AOP 、mock 这类需求
saber000
Jun 21, 2020
4
可以给单元测试提供 spy 的机制吧
About
·
Help
·
Advertise
·
Blog
·
API
·
FAQ
·
Privacy
·
Solana
·
2495 Online
Highest 6679
·
Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 30ms ·
UTC 10:53
·
PVG 18:53
·
LAX 02:53
·
JFK 05:53
♥ Do have faith in what you're doing.
❯