结构体与接口:组合优于继承的 Go 实践
Go 没有继承。类型系统的核心是两个角色:结构体(struct)组织数据,接口(interface)描述行为,两者通过隐式实现连接——一个类型只要拥有接口要求的全部方法,即视为实现了该接口,无需 implements 声明。"组合优于继承"在 Go 中不是风格建议,而是由编译器执行的默认规则。
10 min read
Loading…
Quote of the day · October 26 · 关于意义 · Rick and Morty
Nobody exists on purpose. Nobody belongs anywhere. Everybody's gonna die. Come watch TV?
Notes on Agent runtimes — design decisions laid open: why it is this way, what it costs, and when it stops being true.