知识卡片
符号存在还须满足行为契约
Lookup得到通用符号值,只能证明导出名称存在。宿主还要检查它是否满足预期接口,例如Sayer的Says方法,失败应作为可解释的加载错误。名字和类型两层约定共同构成插件契约,不能把任意interface值当成已验证实现。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Loose Coupling · 查看原书依据
In order for a plugin to be useful, the functions that access it need to know what symbols to look up and what contract those symbols conform to. One convenient — but by no means required — way to do this is to use an interface that a symbol can be expected to satisfy. In
参考来源
- 位置:《Cloud Native Go》第08章《Loose Coupling》(来源项目book-sources;源文件:extracted/Cloud Native Go (Matthew A. Titmus)/_epub-src/OEBPS/ch08.xhtml)
- 结论依据:Lookup得到通用符号值,只能证明导出名称存在。原文相应定义、示例或限制为此结论提供依据;补充纠错与版本边界在正文就近标明。
- 原始内容:In order for a plugin to be useful, the functions that access it need to know what symbols to look up and what contract those symbols conform to. One convenient — but by no means required — way to do this is to use an interface that a symbol can be expected to satisfy. In