我找到了代码
newMap := map[string]interface{}{
"string1" : 1,
"string2" : "hello",
"string3" : map[string]string{
"hello" : "hello there"
}
}
我的猜测是,如果我们使用map for interface作为值类型,那么我们可以将任何类型的值插入值,是否正确?
实际上,它与地图没有任何关系。但回答你的问题是yes
。你可以插入任何你想要的东西。
“A Tour of Go”中空接口的定义
空接口可以保存任何类型的值。 (每种类型至少实现零方法。)
检查A Tour of Go上的示例