如何访问以下代码的地图值?代码片段是自动生成的,所以我无法修改它。我已经尝试过,OpType_name[OpType_UNKNOWN]但我从 golang 编译器中收到错误消息。
type OpType int32
const (
OpType_UNKNOWN OpType = 0
OpType_CREATE OpType = 1
OpType_DELETE OpType = 3
)
var OpType_name = map[int32]string{
0: "UNKNOWN",
1: "CREATE",
2: "DELETE",
}
var OpType_value = map[string]int32{
"UNKNOWN": 0,
"CREATE": 1,
"DELETE": 2,
}
错误: cannot use int(api.OpType_UNKNOWN) (type int) as type int32 in map index
白板的微信
相关分类