To find the length of a map in Go, you can use the built-in len
function. Here's an example:
main.go279 chars14 lines
In this example, we declare and initialize a new map with three key-value pairs. Then, we use the len
function to get the length of the map and assign it to the length
variable. Finally, we print out the length of the map using fmt.Printf
. The output of this program will be:
main.go28 chars2 lines
gistlibby LogSnag