go语言接口的优势?

Views :
Update time : 2025-06-20 19:15:10

就是一个半吊子trait的实现Go的interface是一个残废的实现,一开始意图是允许带有一定约束(方法集)的多态。

但是这玩意又不像rust一样是编译期展开的(当然1.18以后把interface用在泛型上可以视作静态trait的一种实现形式),只要参数位上一用到interface就通通逃逸加装箱变成动态派发。

而且Go中interface是隐式实现加不可区分(non-distinguishable)的,什么意思呢? 例如:在rust里,你两个trait(Plugin 和 Builder)里有…。

go语言接口的优势?
Related News
Read More >>
Blog Post With Youtube Video 为什么现在吹Rust的人这么多?
2025-06-26 02:05:10
为什么现在吹Rust的人这么多?...
Blog Post With Youtube Video 你见过最上进的人是怎样的?
2025-06-26 02:15:11
你见过最上进的人是怎样的?...
Blog Post With Youtube Video 鸿蒙折叠屏笔记本为什么敢卖26999?
2025-06-26 00:40:12
鸿蒙折叠屏笔记本为什么敢卖26999?...
Blog Post With Youtube Video CPU 为什么很少会坏?
2025-06-26 01:45:11
CPU 为什么很少会坏?...

Leave Your Message