您的位置:首页 > 大数据 > 人工智能

如何在Go中检查地图是否包含密钥? - How to check if a map contains a key in Go?

2020-07-10 06:55 381 查看

精选30+云产品,助力企业轻松上云!>>>

问题:

I know I can iterate over a map m by, 我知道我可以在地图迭代m的,

for k, v := range m { ... }

and look for a key but is there a more efficient way of testing a key's existence in a map? 并寻找钥匙,但是有没有更有效的方法来测试地图中钥匙的存在?

I couldn't find the answer in the language spec . 我在语言规范中找不到答案。

解决方案:

参考一: https://stackoom.com/question/8bOp/如何在Go中检查地图是否包含密钥
参考二: https://oldbug.net/q/8bOp/How-to-check-if-a-map-contains-a-key-in-Go
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  go openssl