{"id":5960,"date":"2021-07-11T12:12:28","date_gmt":"2021-07-11T06:42:28","guid":{"rendered":"https:\/\/golangbyexamples.com\/?p=5960"},"modified":"2021-07-12T10:26:27","modified_gmt":"2021-07-12T04:56:27","slug":"check-map-key-golang","status":"publish","type":"post","link":"https:\/\/golangbyexamples.com\/check-map-key-golang\/","title":{"rendered":"How to check if a map contains a key in Go (Golang)"},"content":{"rendered":"\n

Below is the format to check if a key exists 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