{"id":2208,"date":"2020-06-08T23:59:59","date_gmt":"2020-06-08T18:29:59","guid":{"rendered":"https:\/\/golangbyexamples.com\/?p=2208"},"modified":"2020-06-09T00:00:09","modified_gmt":"2020-06-08T18:30:09","slug":"length-map-golang","status":"publish","type":"post","link":"https:\/\/golangbyexamples.com\/length-map-golang\/","title":{"rendered":"Length of a map in Go (Golang)"},"content":{"rendered":"\n
The golang builtin function len()<\/strong> can be used to get the length of the map which is number of key-value pairs present in the map. Below is the format for using this function on the map.<\/p>\n\n\n\n Let’s see a program<\/p>\n\n\n\n Output<\/strong><\/p>\n\n\n\n The golang builtin function len() can be used to get the length of the map which is number of key-value pairs present in the map. Below is the format for using this…<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[1],"tags":[3,4,294,295],"class_list":["post-2208","post","type-post","status-publish","format-standard","hentry","category-tech","tag-go","tag-golang","tag-length","tag-map"],"yoast_head":"\nlen(mapName)<\/code><\/pre>\n\n\n\n
package main\n\nimport \"fmt\"\n\nfunc main() {\n \/\/Declare\n employeeSalary := make(map[string]int)\n\n \/\/Adding a key value\n employeeSalary[\"Tom\"] = 2000\n employeeSalary[\"Sam\"] = 1200\n\n lenOfMap := len(employeeSalary)\n fmt.Println(lenOfMap)\n}<\/code><\/pre>\n\n\n\n
2<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"