目前 Go 泛型的最佳解决方法是?

2020 年 2 月 20 日
 szzhiyang
9579 次点击
所在节点    Go 编程语言
42 条回复
notamail
2020 年 3 月 6 日
sunshinev
2020 年 5 月 6 日
如果明确自己想要的东西,那么一般用不到 interface{} 就是要费尽把 struct 定义好。 不过很 base 的 struct 可能会有 interface{} 来解析 web 的数据,比如像定义一个 type Ret struct { Code: int Data:interface{} }

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://study.congcong.us/t/646217

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX