{"id":2216,"date":"2020-06-09T14:33:46","date_gmt":"2020-06-09T09:03:46","guid":{"rendered":"https:\/\/golangbyexamples.com\/?p=2216"},"modified":"2020-06-09T14:33:58","modified_gmt":"2020-06-09T09:03:58","slug":"check-key-exists-map-golang","status":"publish","type":"post","link":"https:\/\/golangbyexamples.com\/check-key-exists-map-golang\/","title":{"rendered":"An efficient way to check if a key exists in a Map in Go (Golang)"},"content":{"rendered":"\n

Below is the format to check if a key exist in the map<\/p>\n\n\n\n

val, ok := mapName[key]<\/code><\/pre>\n\n\n\n

There are two cases<\/p>\n\n\n\n