go - 在没有泛型的情况下在 Golang 中重用类似的代码
问题描述
鉴于我有一个 MyMap 类型的变量
*map[uuid.UUID][]*Thing
和这样的一段代码:
h.MyMap[id] = append(h.MyMap[id], &thingA)
// other stuff with MyMap like this, later:
h.MyMapp[id][k] = &thingB
// and so on... the actual code is way more complex
和上面一样的代码,除了它使用类型的映射:
*map[int64][]*Thing
有没有一种 Golang 方法来干燥它并编写一个在一个地方执行类似代码的助手?
谢谢你。
解决方案
[我]有没有一种 Golang 方法来干燥它并编写一个在一个地方执行类似代码的助手?
不。
推荐阅读
- java - 如何访问在 Java 中用作对象属性的数组?
- ios - 无法以编程方式设置 UILabel/UITextView 的高度
- .net - System.DirectoryServices.AccountManagement 正在查询不再生产的 DC
- javascript - 承诺抛出错误,因为它无法访问它
- firebase - firebase 没有给我我需要的权限
- jquery - 如何在引导程序 4 的一行中循环 4 列?
- python - 电子商务网站如何与ERP系统集成?
- javascript - 在数组的开头添加一个对象
- php - SQL插入不要让我插入超过20列
- visual-studio - 如何在 Visual Studio 2015 中调试 VB 6 二进制文件