问题:
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
来源:oschina
链接:https://my.oschina.net/stackoom/blog/4348227