下面的代码没有按预期工作。
package main
import "fmt"
func main() {
questions := make(map[int]interface{})
questions[1] = map[interface{}]string{
"q1": "This is Question - 1?",
"op1": "This is Option - 1",
"op2": "This is Option - 2",
true: "This is Option - 1",
}
// This give map[interface {}]string
fmt.Printf("%T \n", questions[1])
// This not working
for key, val := range questions[1] {
printf("%v : %v", key, val)
}
}
遍及地图的 for 循环不起作用。
Go 编译器给出错误“无法范围覆盖问题 [1](类型接口 {})”
慕田峪4524236
相关分类